We’re rewarding the question askers & reputations are being recalculated! Read more.
2 deleted 18 characters in body; edited title
source | link

Review my Zepto / jQuery plugin base

I am looking for a starting point to code plugins, primarily for Zepto.js (with fall back for jQuery). These will provide reusable functions for Tumblr theming.

However, I can't seem to find anything in depth about writing a plugin (with Zepto) as the example, apart from a small snippet on the Zepto site: http://zeptojs.com/

The code below is pieced together from reading various 'jQuery' plugin tutorials, but I am not 100% sure how solid it is.

;(function($){
    $.extend($.fn, {
        pluginName: function(el, options) {
            // Set defaults
            this.defaults = {
                option: 'option',
                onComplete: function() {}
            };
            // Combine defaults / options
            var settings = $.extend({}, this.defaults, options);
            // Do stuff
            $.each(this, function() {

            });
            // Call back if needed
            settings.onComplete.call(this);
            // Return `this` for chain ability
            return this;
        }
    });
}(window.Zepto || window.jQuery));

According to the Zepto documentation, my plugins method will be added to the Zepto object. Is this acceptable?

I would also like the option to use private / public functions contained in the plugin for flexibility.

I apologise if my questions come across as confusing or novice, but any help / improvements would be greatly appreciated.

Thanks

Mike

Review my Zepto / jQuery plugin base

I am looking for a starting point to code plugins, primarily for Zepto.js (with fall back for jQuery). These will provide reusable functions for Tumblr theming.

However, I can't seem to find anything in depth about writing a plugin (with Zepto) as the example, apart from a small snippet on the Zepto site: http://zeptojs.com/

The code below is pieced together from reading various 'jQuery' plugin tutorials, but I am not 100% sure how solid it is.

;(function($){
    $.extend($.fn, {
        pluginName: function(el, options) {
            // Set defaults
            this.defaults = {
                option: 'option',
                onComplete: function() {}
            };
            // Combine defaults / options
            var settings = $.extend({}, this.defaults, options);
            // Do stuff
            $.each(this, function() {

            });
            // Call back if needed
            settings.onComplete.call(this);
            // Return `this` for chain ability
            return this;
        }
    });
}(window.Zepto || window.jQuery));

According to the Zepto documentation, my plugins method will be added to the Zepto object. Is this acceptable?

I would also like the option to use private / public functions contained in the plugin for flexibility.

I apologise if my questions come across as confusing or novice, but any help / improvements would be greatly appreciated.

Thanks

Mike

Zepto / jQuery plugin base

I am looking for a starting point to code plugins, primarily for Zepto.js (with fall back for jQuery). These will provide reusable functions for Tumblr theming.

However, I can't seem to find anything in depth about writing a plugin (with Zepto) as the example, apart from a small snippet on the Zepto site: http://zeptojs.com/

The code below is pieced together from reading various 'jQuery' plugin tutorials, but I am not 100% sure how solid it is.

;(function($){
    $.extend($.fn, {
        pluginName: function(el, options) {
            // Set defaults
            this.defaults = {
                option: 'option',
                onComplete: function() {}
            };
            // Combine defaults / options
            var settings = $.extend({}, this.defaults, options);
            // Do stuff
            $.each(this, function() {

            });
            // Call back if needed
            settings.onComplete.call(this);
            // Return `this` for chain ability
            return this;
        }
    });
}(window.Zepto || window.jQuery));

According to the Zepto documentation, my plugins method will be added to the Zepto object. Is this acceptable?

I would also like the option to use private / public functions contained in the plugin for flexibility.

I apologise if my questions come across as confusing or novice, but any help / improvements would be greatly appreciated.

    Tweeted twitter.com/#!/StackCodeReview/status/334037157079568384
1
source | link

Review my Zepto / jQuery plugin base

I am looking for a starting point to code plugins, primarily for Zepto.js (with fall back for jQuery). These will provide reusable functions for Tumblr theming.

However, I can't seem to find anything in depth about writing a plugin (with Zepto) as the example, apart from a small snippet on the Zepto site: http://zeptojs.com/

The code below is pieced together from reading various 'jQuery' plugin tutorials, but I am not 100% sure how solid it is.

;(function($){
    $.extend($.fn, {
        pluginName: function(el, options) {
            // Set defaults
            this.defaults = {
                option: 'option',
                onComplete: function() {}
            };
            // Combine defaults / options
            var settings = $.extend({}, this.defaults, options);
            // Do stuff
            $.each(this, function() {

            });
            // Call back if needed
            settings.onComplete.call(this);
            // Return `this` for chain ability
            return this;
        }
    });
}(window.Zepto || window.jQuery));

According to the Zepto documentation, my plugins method will be added to the Zepto object. Is this acceptable?

I would also like the option to use private / public functions contained in the plugin for flexibility.

I apologise if my questions come across as confusing or novice, but any help / improvements would be greatly appreciated.

Thanks

Mike