Created
January 31, 2013 05:25
-
-
Save keelii/4680477 to your computer and use it in GitHub Desktop.
jQuery Plugin Design Pattern for us
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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