The following is a handy template that I use for myself.
(function($){
var MyClass = function (element, options){
this.options = $.extend({}, options);
this.someFunction = function (){...}
var otherFunction = function(){...}
$(element).data('pluginInstance', this);
}
$.fn.myPlugin = function(options){
var myClassInstace = new MyClass(this, options);
}
})(jQuery);
source
share