javascript Jquery自动完成自定义数据错误没有自动完成小部件实例的这种方法“实例”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30365669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery autocomplete custom data error no such method 'instance' for autocomplete widget instance
提问by Anuja Deshpande Patil
I am adding the autocomplete functionality to text box. Referring thisjQuery autocomplete custom data plugin.
我正在向文本框添加自动完成功能。参考这个jQuery 自动完成自定义数据插件。
Without custom data code it is working fine. I have added following custom data code
没有自定义数据代码它工作正常。我添加了以下自定义数据代码
.autocomplete( "instance" )._renderItem = function( ul, item ) {
return $( "<li>" )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo( ul );
};
it throws error as
它抛出错误
no such method 'instance' for autocomplete widget instance
自动完成小部件实例没有这样的方法“实例”
is there anything that I am missing.
有什么我想念的吗?
I am using jQuery v1.11.2 and jQuery UI - v1.10.3
我正在使用 jQuery v1.11.2 和 jQuery UI - v1.10.3
回答by Anuja Deshpande Patil
Updated the syntax for the new version: I think they are not using instance now.
更新了新版本的语法:我认为他们现在没有使用实例。
$("#Id").autocomplete().data("uiAutocomplete")._renderItem = function( ul, item )
{
return $( "<li>" )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo( ul );
};