Sha256: 36c672401b269ac31713eadbbc4e3d85d0d61d97f59fbed92f972940e1378a92
Contents?: true
Size: 1.48 KB
Versions: 72
Compression:
Stored size: 1.48 KB
Contents
(function($) { $.fn.udongo_tagbox = function(options) { var settings = $.extend({ items: 'items-path', limit: null, minLength: 2, on_add: function(tag, input) {}, on_remove: function(tag, input) {} }, options); return this.each(function() { var input = $(this); if(typeof settings.items == 'string'){ $.ajax({ type: 'GET', url: input.data(settings.items) }).done(function(data){ settings.items = data; return tagit(input, settings.items); }); } else { return tagit(input, settings.items); } function tagit(input, items) { input.tagit({ autocomplete: { minLength: settings.minLength, source: function(request, response) { response($.ui.autocomplete.filter(settings.items, request.term)); } }, allowSpaces: true, caseSensitive: false, removeConfirmation: true, tagLimit: settings.limit, beforeTagAdded: function(event, ui) { if($.isFunction(settings.on_add)){ settings.on_add.call(this, ui.tag.find('.tagit-label').text(), input); } }, afterTagRemoved: function(event, ui) { if($.isFunction(settings.on_remove)){ settings.on_remove.call(this, ui.tag.find('.tagit-label').text(), input); } } }); } }); }; }(jQuery));
Version data entries
72 entries across 72 versions & 1 rubygems