我需要允许用户在tagSource中选择仅允许的标签。
目前我有:
var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
$("#myTags").tagit({
tagSource: sampleTags
});
你能帮帮我吗?
答案 0 :(得分:1)
检查一下它是否可行
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);
}
}
});