【问题标题】:javascript tag-it allowed tagsjavascript tag-it 允许的标签
【发布时间】:2016-03-08 16:25:19
【问题描述】:

我需要允许用户在 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 
});

tag-it in GitHub

Tag-it! Usage Examples

你能帮帮我吗?

【问题讨论】:

  • $("#myTags").tagit({ availableTags: ["c++", "java", "php", "javascript", "ruby", "python", "c"] });

标签: javascript jquery tag-it


【解决方案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);
        }
    }
    });

【讨论】:

  • 但用户仍然可以创建新标签。
猜你喜欢
  • 1970-01-01
  • 2013-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-23
  • 2012-10-10
  • 1970-01-01
相关资源
最近更新 更多