哪些解决方案实现了SO用于输入标签的相同自动完成功能?
有插件可以处理一个单词,但我还没有看到任何处理多个单词的插件.
我使用以下代码片段与ajax远程添加一个新的select2标签,我想在新标签/删除标签事件上注册或删除我的多对多表的一些记录
表看起来像
---------------------------------
+--voucher_id--+|+--product_id--+
---------------------------------
+ 123 | 566 +
---------------------------------
+ 156 | 566 +
---------------------------------
+ 123 | 426 +
---------------------------------
+ 156 | 516 +
---------------------------------
Run Code Online (Sandbox Code Playgroud)
我的Javascript
$(".e6").select2({
tags: true,
placeholder: 'placeholder',
minimumInputLength: 1,
ajax: {
url: 'searchProducts',
dataType: 'json',
data: function(term) {
return {q: term};
},
results: function(data) {
return {results: data};
}
},
createSearchChoice: function(term, data) {
if ($(data).filter(function() {
return this.computername.localeCompare(term) === 0;
}).length === 0) {
return {id: term, name: term}; …Run Code Online (Sandbox Code Playgroud)