Return to Snippet

Revision: 51444
at September 25, 2011 02:49 by realpeterz


Updated Code
;(function($) {

    $.pluginName = function(el, options) {

        var defaults = {
            propertyName: 'value',
            onSomeEvent: function() {}
        },

        plugin = this;

        plugin.settings = {};

        var init = function() {
            plugin.settings = $.extend({}, defaults, options);
            plugin.el = el;
            plugin.$el = $(el);
            // code goes here
        };

        plugin.fooPublicMethod = function() {
            // code goes here
        };

        var fooPrivateMethod = function() {
            // code goes here
        };

        init();

    }

})(jQuery);


// Uages


$(document).ready(function() {

   // create a new instance of the plugin
   var myplugin = new $.pluginName($('#element'), {option: "value"});

   // call a public method
   myplugin.fooPublicMethod();

   // get the value of a public property
   myplugin.settings.property;

});

Revision: 51443
at September 24, 2011 15:31 by realpeterz


Initial Code
;(function($) {

    $.videoToggle = function(el, options) {

        var defaults = {
            propertyName: 'value',
            onSomeEvent: function() {}
        }

        var plugin = this;

        plugin.settings = {}

        var init = function() {
            plugin.settings = $.extend({}, defaults, options);
            plugin.el = el;
            // code goes here
        }

        plugin.fooPublicMethod = function() {
            // code goes here
        }

        var fooPrivateMethod = function() {
            // code goes here
        }

        init();

    }

})(jQuery);


// Uages


$(document).ready(function() {

   // create a new instance of the plugin
   var myplugin = new $.pluginName($('#element'));

   // call a public method
   myplugin.fooPublicMethod();

   // get the value of a public property
   myplugin.settings.property;

});

Initial URL
http://jqueryboilerplate.com/

Initial Description

                                

Initial Title
jQuery plugin boilderplate

Initial Tags

                                

Initial Language
jQuery