试图让tag-it与ajax调用一起使用.
到目前为止一切都有效.除此之外,我无法通过ajax调用分配tagSource.
在萤火虫中,'数据'正在返回:
["Ruby","Ruby On Rails"]
Run Code Online (Sandbox Code Playgroud)
但是当我输入输入框时它没有显示出来.
$('.tags ul').tagit({
itemName: 'question',
fieldName: 'tags',
removeConfirmation: true,
availableTags: ["c++", "java", "php", "javascript", "ruby", "python", "c"],
allowSpaces: true,
// tagSource: ['foo', 'bar']
tagSource: function() {
$.ajax({
url: "/autocomplete_tags.json",
dataType: "json",
data: { term: 'ruby' },
success: function(data) {
console.log(data);
return data;
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
console.log(data)回报["Ruby", "Ruby On Rails"].
我在这里错过了什么吗?还有其他人上班吗?