Created
September 13, 2012 10:25
-
-
Save nmsdvid/3713432 to your computer and use it in GitHub Desktop.
jQuery plugin pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* <plugin name> | |
* version <number> | |
* author: <author name> | |
* <web site, twitter, etc...> | |
*/ | |
(function($){ | |
function initialize($obj, option1, option2, option3){ | |
// code here | |
}; | |
// plugin name | |
$.fn.plugin_name = function(options){ | |
//set defaults | |
var defaults = { | |
option1: "value", | |
option2: "value", | |
option3: "value" | |
}; | |
var option = $.extend(defaults, options); | |
return this.each(function(){ | |
var $this = $(this); | |
initialize($this, option.option1, option.option2, option.option3); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment