Skip to content

Instantly share code, notes, and snippets.

@beshkenadze
Last active October 11, 2015 17:08
Show Gist options
  • Save beshkenadze/3891808 to your computer and use it in GitHub Desktop.
Save beshkenadze/3891808 to your computer and use it in GitHub Desktop.
template for jquery plugin
!function( $ ){
"use strict"
var Taggable = function ( element, options ) {
this.$element = $(element);
this.options = $.extend({}, $.fn.taggable.defaults, options);
this.initialize();
}
Taggable.prototype = {
constructor: Taggable
, initialize : function () {
}
}
$.fn.taggable = function ( option ) {
return this.each(function () {
var $this = $(this)
, data = $this.data('taggable')
, options = typeof option == 'object' && option;
if (!data) $this.data('taggable', (data = new Taggable(this, options)));
if (typeof option == 'string') data[option]();
})
}
$.fn.taggable.defaults = {
}
$.fn.taggable.Constructor = Taggable;
}( window.jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment