【问题标题】:use an external Json as source with tagit.js使用外部 Json 作为 tagit.js 的源
【发布时间】:2014-10-26 23:10:40
【问题描述】:

我的 tagit.js 脚本有问题 (https://github.com/aehlke/tag-it) 我知道以前有人问过这类问题: Modify the behavior of jquery tag-it based on autocomplete library to use ajax JSON sources 要么 jQuery TagIt (autocomplete) Fetching JSON list via AJAX

就我而言,我可以从外部 json 加载标签,但没有智能自动完成功能。当我输入“Hello”时,插件会显示我 Json 上的整个标签,没有逻辑顺序。

我的代码:

  $(function(){

       $('#biginput').tagit({

            allowSpaces:true,

            autocomplete: {delay: 0, minLength: 0},
            afterTagAdded: function(event, ui) {
                launchsearch();
                console.log(ui.tag);
            },
            afterTagRemoved: function(event, ui) {
                launchsearch();
                console.log(ui.tag);
            },



             tagSource: function(search, showChoices) {
                var that = this;
                $.ajax({
                  url: "search.json",
                  data: search,
                  success: function(choices) {
                    showChoices(that._subtractArray(choices, that.assignedTags()));
                  }
                });
              }


        });

});

我试图在 jsfiddle 中重现我的问题,但它不起作用...... 看这里:http://jsfiddle.net/bsofcn41/ 我的目标只是让标签自动完成以 json 文件为基础。

似乎这个脚本在 github 中的更新和维护非常糟糕。也许有这种更好的脚本?

【问题讨论】:

    标签: javascript jquery ajax json autocomplete


    【解决方案1】:

    试试jquery-tokeninput。它使用 json 作为自动完成数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-01
      • 2018-03-19
      • 2021-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多