Tagit Jquery 插件的自动完成属性写成如下:
autocomplete: {
source: function( request, response ) {
$.ajax({
url: baseURL,
dataType: "json",
data: {
query:request.term
},
success: function( data ) {
response( $.map( data, function( item ) {
return {
label: item.label + "<br />" +item.description,
value: item.label
}
}));
}
});
}
所有工作正常,除了返回线,如您所见 <br>
嵌入在 Label
之间和 description
的项目。
Tag-it 解释的问题 <br>
比如纯文本。
我读了 here :
If you're using a custom jQuery UI build, it must contain the Core, Widget, Position, and Autocomplete components. The Effects Core with "Blind" and "Highlight" Effect components are optional, but used if available.
我不知道如何设置自定义 HTML
更新:
已知如果是autocomplete插件,我们可以使用:
$('ul').autocomplete({...}).data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label +"<br>"+item.description+ "</a>")
.appendTo(ul);
};
但是,当我应用 .data("autocomplete")._renderItem
在 tag-it 插件中,我收到错误。
$('ul').tagit({autocomplete:{/*....*/}}).data("autocomplete")._renderItem=fn /*...*/
最佳答案
这对我有用
$('ul').find("input").data("uiAutocomplete")._renderItem = function (ul, item) { };
关于html - 使用自定义 HTML 作为 Tag-it 自动完成的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20298940/