Last active
October 11, 2015 17:08
-
-
Save beshkenadze/3891808 to your computer and use it in GitHub Desktop.
template for jquery plugin
This file contains hidden or 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( $ ){ | |
"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