diff --git a/jquery.tagsinput.js b/jquery.tagsinput.js index 5c9b89a..8133d72 100644 --- a/jquery.tagsinput.js +++ b/jquery.tagsinput.js @@ -20,7 +20,6 @@ var tags_callbacks = new Array(); $.fn.addTag = function(value,options) { - var options = jQuery.extend({focus:false,callback:true},options); this.each(function() { id = $(this).attr('id'); @@ -63,7 +62,6 @@ }; $.fn.removeTag = function(value) { - value = unescape(value); this.each(function() { id = $(this).attr('id'); @@ -88,11 +86,9 @@ }); return false; - }; $.fn.tagExist = function(val) { - if (jQuery.inArray(val, $(this)) == -1) { return false; /* Cannot find value in array */ } else { @@ -107,7 +103,6 @@ } $.fn.tagsInput = function(options) { - var settings = jQuery.extend({interactive:true,defaultText:'add a tag',minChars:0,width:'300px',height:'100px','hide':true,'delimiter':',',autocomplete:{selectFirst:false},'unique':true,removeWithBackspace:true},options); this.each(function() { @@ -247,7 +242,7 @@ if(tags_callbacks[id] && tags_callbacks[id]['onChange']) { var f = tags_callbacks[id]['onChange']; - f(obj); + f(obj, tags[i]); } }; diff --git a/test.html b/test.html index 2693c73..f9dad99 100644 --- a/test.html +++ b/test.html @@ -19,7 +19,18 @@ } $(function() { - $('input.tags').tagsInput(); + $('#tags_1').tagsInput(); + $('#tags_2').tagsInput({ + onChange: function(elem, elem_tags) + { + var languages = ['php','ruby','javascript']; + $('.tag', elem_tags).each(function() + { + if($(this).text().search(new RegExp('\\b(' + languages.join('|') + ')\\b')) >= 0) + $(this).css('background-color', 'yellow'); + }); + } + }); // Uncomment this line to see the callback functions in action // $('input.tags').tagsInput({onAddTag:onAddTag,onRemoveTag:onRemoveTag}); @@ -38,6 +49,9 @@
+ + +