Last active
March 31, 2017 06:12
-
-
Save musukvl/c8b351f7854932c8f61c13c910845d23 to your computer and use it in GitHub Desktop.
JQuery Plugin Template
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 = function (el, options) { | |
// To avoid scope issues, use 'self' instead of 'this' | |
// to reference this class from internal events and functions. | |
var self = this; | |
// Access to jQuery and DOM versions of element | |
self.$el = $(el); | |
self.el = el; | |
self.elId = self.$el.attr('id'); | |
// Add a reverse reference to the DOM object | |
self.$el.data("pluginName", self); | |
self.init = function () { | |
self.options = $.extend({}, $.pluginName.defaultOptions, options); | |
self.$el.click(onStarClick); | |
//subscribe to element events | |
}; | |
// Run initializer | |
self.init(); | |
}; | |
$.pluginName.defaultOptions = { | |
cookieKey: 'pluginName' | |
}; | |
$.fn.pluginName = function (options) { | |
return this.each(function () { | |
(new $.pluginName(this, options)); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment