Skip to content

Instantly share code, notes, and snippets.

@keelii
Created January 31, 2013 05:25
Show Gist options
  • Save keelii/4680477 to your computer and use it in GitHub Desktop.
Save keelii/4680477 to your computer and use it in GitHub Desktop.
jQuery Plugin Design Pattern for us
(function ($) {
/**
* pluginName插件
*/
var pluginName = function (that, options, callback) {
this.opts = $.extend({
content: that.title || '',
options: 'you want to set'
}, options);
this.$obj = $(that);
this.callback = callback || function() {};
this.init();
};
pluginName.prototype = {
init: function() {
}
};
$.fn.pluginName = function (options, callback) {
return this.each(function () {
var plugin = new pluginName(this, options, callback);
$(this).data('pluginName', plugin);
});
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment