Skip to content

Instantly share code, notes, and snippets.

@nmsdvid
Created September 13, 2012 10:25
Show Gist options
  • Save nmsdvid/3713432 to your computer and use it in GitHub Desktop.
Save nmsdvid/3713432 to your computer and use it in GitHub Desktop.
jQuery plugin pattern
/*
* <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