Reputation: 119
I need to allow users select ONLY allowed tags in tagSource.
Currently I have that:
var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
$("#myTags").tagit({
tagSource: sampleTags
});
Can you help me please with that?
Upvotes: 2
Views: 163
Reputation: 1082
check this it will work
var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
$("#myTags").tagit({
availableTags: sampleTags,
afterTagAdded: function (event, ui) {
if ($.inArray(ui.tagLabel, sampleTags) == -1) {
$("#myTags").tagit("removeTagByLabel", ui.tagLabel);
}
}
});
Upvotes: 1