【发布时间】: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