Skip to content

Instantly share code, notes, and snippets.

@Fedik
Last active August 29, 2015 14:05
Show Gist options
  • Save Fedik/fa9286022ab9890c30b4 to your computer and use it in GitHub Desktop.
Save Fedik/fa9286022ab9890c30b4 to your computer and use it in GitHub Desktop.
jQuery.dummyPlugin
;(function($){
"use strict";
$.dummyPlugin = function(element, options){
self.$element = $(element);
// merge options
this.options = $.extend({}, $.dummyPlugin.defaults, options);
// initialisation and other plugin code
};
// defaults
$.dummyPlugin.defaults = {
key: 'value'
};
$.fn.dummyPlugin = function(options){
var instance = $(this).data('dummyPlugin');
if(!instance){
instance = new $.dummyPlugin(this, options);
$(this).data('dummyPlugin', instance);
}
return instance;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment