Skip to content

Instantly share code, notes, and snippets.

@ahmetvurgun
Forked from ornj/plugin.js
Created July 2, 2012 14:16
Show Gist options
  • Save ahmetvurgun/3033470 to your computer and use it in GitHub Desktop.
Save ahmetvurgun/3033470 to your computer and use it in GitHub Desktop.
jQuery Plugin Template
(function($) {
var methods = {
init: function(options) {
},
update: function(options) {
},
destroy: function() {
}
};
$.fn.MY_PLUGIN_NAME = function(method_options) {
if (methods[method_options]) {
return methods[method_options].apply(this, Array.prototype.slice.call(arguments, 1));
}
else if (typeof method_options === 'object' || !method_options) {
return methods.init.apply(this, arguments);
}
else {
$.error('Method ' + method + 'does not exist. What are you doing?');
}
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment