GithubHelp home page GithubHelp logo

jquery-plugin-boilerplate's Introduction

Hi ๐Ÿ‘‹, I'm Antonio Santiago

A software engineer from Barcelona, Catalonia

Software engineer ๐Ÿ’ป by vocation and hobby ๐Ÿค“ Ocasionally a tech writer ๐Ÿ–Š Restless mind ๐Ÿฆ„ I love programming as a tool to give wings to creativity ๐Ÿคช Technology is the means, not the end ๐Ÿ I start many things and finish few. Frustrated musician ๐ŸŽธ I like music that transmits emotions to me. I forget the sorrows doing sports ๐Ÿ‹๏ธ

  • ๐Ÿ”ญ Iโ€™m currently working on Joppy
  • ๐ŸŒฑ Iโ€™m currently learning to be an entrepreneur and how to growing a company
  • ๐Ÿ‘ฏ Iโ€™m looking to collaborate on helping others making ideas into reality
  • ๐Ÿค Iโ€™m looking for help with to create the best recruitment platform for techies
  • ๐Ÿ“ I regularly write articles on https://www.acuriousanimal.com
  • ๐Ÿ’ฌ Ask me about whatever you want. I'll try top help you within my possibilities

Connect with me:

acanimal acanimal acanimal acuriousanimal 98qwsBNAfr https://www.acuriousanimal.com/rss.xml

Languages and Tools:

angular aws babel bootstrap css3 cypress docker elasticsearch electron express firebase gatsby gcp git grafana graphql gulp html5 jasmine javascript jekyll jenkins jest kibana mocha mongodb mysql nextjs nginx nodejs php postgresql puppeteer react reactnative redis redux sass spring symfony typescript webpack

jquery-plugin-boilerplate's People

Contributors

acanimal avatar odahcam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jquery-plugin-boilerplate's Issues

Methods that require a return value are not returned, instead, as written, method return jQuery object

Greetings, using your template, we needed a method to return values.
For example,

var myvalue = $('#foo').myPlugin('methodThatShouldReturnValue') ;

As written here, this is not allowing the return value in methodThatShouldReturnValue to pass through:

 // Invoke the specified method on each selected element
                return this.each(function() {
                    var instance = $.data(this, 'plugin_' + pluginName);
                    if (instance instanceof Plugin && typeof instance[options] === 'function') {
                        instance[options].apply(instance, Array.prototype.slice.call(args, 1));
                    }
                });

It does not allow return value of the method to be returned, instead 'return this.each...' is only return jQuery object.

I've altered it like this, but perhaps you have a more elegant solution:

 // Invoke the speficied method on each selected element
                var results ;
                 this.each(function() {
                    var instance = $.data(this, 'plugin_' + pluginName);
                    if (instance instanceof Plugin && typeof instance[options] === 'function') {
                        results = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
                    }
                });
              return results ;

Note, in our plugin, that method is only applied to one id on the dom, not multiple.

In the case of multiple return values required, that code could be written like this:

 // Invoke the speficied method on each selected element
                var results = [] ;
                 this.each(function() {
                    var instance = $.data(this, 'plugin_' + pluginName);
                    if (instance instanceof Plugin && typeof instance[options] === 'function') {
                        results.push( instance[options].apply(instance, Array.prototype.slice.call(args, 1)) ) ;
                    }
                });
              return results ;

Again, perhaps you have a preferred way to rewrite the code to account for both scenarios and return appropriately.

Duplication

Although this one of the most sane ways of doing jQuery plugins, there is duplication there for the getters, what do you think of another convention by using get prefix in names of getters so that you automatically introspect and export them automatically instead of retyping it in the getters ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.