簡體   English   中英

使用外部Json作為tagit.js的源

[英]use an external Json as source with tagit.js

我的tagit.js腳本有一些問題( https://github.com/aehlke/tag-it )我知道以前已經問過這類問題: 基於自動完成庫修改jquery tag-it的行為以使用ajax JSON源jQuery TagIt(自動完成)通過AJAX獲取JSON列表

就我而言,我可以從外部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中的更新和維護非常糟糕。 也許有更好的這種腳本?

嘗試jquery-tokeninput 它使用json作為自動完成數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM