html - 使用自定义 HTML 作为 Tag-it 自动完成的结果

标签 html autocomplete tag-it

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>比如纯文本。

enter image description here

我读了 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/

相关文章:

java - jsp中的自动完成文本框

jquery - 如何自定义tag-it jQuery插件: needs to add image for each found item

css - jquery Tag-it 插件的输入字段样式

html - Chrome 边框半径和背景颜色

javascript - js后台视频调整中心

html - 不知道为什么setAttribute()对音频元素不起作用

google-apps-script - 如何在本地安装的 IDE 中启用 Google Apps 脚本的自动完成功能

ios - 如何在 Iphone Phonegap 中播放内联视频

javascript - 如何更改自动完成中的结果过滤器?

php - Jquery Tagit - 如何将键入的标签传递回 PHP