From b56a968f97a79b68620487e1592c191ab3fc3096 Mon Sep 17 00:00:00 2001 From: Tomasz Tybulewicz Date: Tue, 13 Mar 2012 19:59:46 +0100 Subject: [PATCH] Fixed issue #49 - tagExist() now works correctly --- jquery.tagsinput.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jquery.tagsinput.js b/jquery.tagsinput.js index da274a1..8dfa710 100644 --- a/jquery.tagsinput.js +++ b/jquery.tagsinput.js @@ -86,7 +86,7 @@ value = jQuery.trim(value); if (options.unique) { - var skipTag = $(tagslist).tagExist(value); + var skipTag = $(this).tagExist(value); if(skipTag == true) { //Marks fake input as not_valid to let styling it $('#'+id+'_tag').addClass('not_valid'); @@ -162,7 +162,9 @@ }; $.fn.tagExist = function(val) { - return (jQuery.inArray(val, $(this)) >= 0); //true when tag exists, false when not + var id = $(this).attr('id'); + var tagslist = $(this).val().split(delimiter[id]); + return (jQuery.inArray(val, tagslist) >= 0); //true when tag exists, false when not }; // clear all existing tags and import new ones from a string