I ran into the same problem, so I used the @Ravindra (+1 BTW) hint to see if I can reverse engineer the plug-in and figure out how the tagSource function is expected to return.
The tagSource function returns a boolean value. True is returned if the tag in the array of available tags is displayed in the autocomplete list. False is returned to indicate that the tag should not be displayed.
Here is the default tagSource function that uses indexOf to determine if the text typed so far matches the beginning of the tag in the array of available tags:
Original, default function:
tagSource: function(search, showChoices) { var filter = search.term.toLowerCase(); var choices = $.grep(this.options.availableTags, function(element) {
I copied the function and embedded it in a .tagit function, so it was included as one of the parameters passed to the jQuery tag tag initialization function. Then I modified it to use a matching method that uses pattern matching to return the portion of the string matching the pattern. If the match returns null, do not show it in the list. If it returns anything else, show the tag in the list:
A modified function passed as an argument:
tagSource: function(search, showChoices) { var filter = search.term.toLowerCase(); var choices = $.grep(this.options.availableTags, function(element) {
Example:
$('#tagged').tagit({ onTagRemoved: function() { alert("Removed tag"); }, availableTags: [ "one" , "two one" , "three" , "four" , "five" ], // override function to modify autocomplete behavior tagSource: function(search, showChoices) { var filter = search.term.toLowerCase(); var choices = $.grep(this.options.availableTags, function(element) { // Only match autocomplete options that begin with the search term. // (Case insensitive.) //return (element.toLowerCase().indexOf(filter) === 0); console.info(element.toLowerCase().match(filter) + " : " + element + " : " + filter); return (element.toLowerCase().match(filter) !== null); }); showChoices(this._subtractArray(choices, this.assignedTags())); } });