Return to Snippet

Revision: 22011
at December 28, 2009 16:50 by mdrisser


Initial Code
// Create Closure
(function($) {
    $.fn.PLUGIN_NAME = function(options) {
        // Extend the defaults, over-writing them with anything passed by the caller
        var opts = $.extend({}, $.fn.PLUGIN_NAME.defaults, options);
		
        // Iterate over each element
        return this.each(function() {
            $this = $(this);
			
            // Allow for use of the Metadata plugin
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
            // YOUR CODE GOES HERE
			
        });
    };
	
    // Additional methods follow the format:
    // $.fn.PLUGIN_NAME.format = function(txt) {
        // FUNCTION STUFF GOES HERE
    // };
	
    // Plugin Defaults
    $.fn.PLUGIN_NAME.defaults = {
		
    };
})(jQuery);    // Closure Closed

Initial URL


Initial Description
Pretty straight forward. Replace 'PLUGIN_NAME' with the name of your plugin, add your code in the appropriate places, test and deploy.

Should be pretty easy to use, I commented it heavily.

Initial Title
jQuery Plugin Template

Initial Tags
jquery

Initial Language
JavaScript