Reputation: 399
I am using jQuery-TokenInput in my application.I have some list of items, so when we enter any text if it is matched with the text in the list then it should not be added.
For example: If I had a list["abc","def","xyz"].
So if we enter in "xyz" in the jQuery-TokenInput textbox, it should not add.
Thanks,
Naresh.
Upvotes: 0
Views: 948
Reputation: 6042
I'd work with the onAdd
event, and use the remove
function call. Try something along these lines. (It will need debugging, but I think the principle should work.)
var list = ["abc","def","xyz"];
var newTI = $("#myTI").tokenInput("search.php", {
propertyToSearch: "val",
onAdd: function(item){
if ($.inArray(list,item.val)) selector.tokenInput("remove", item);
},
});
Upvotes: 1