我最近将 jquery 从 1.8 更新到 1.11,jquery 组合框爆炸了。
起初它给出了 _renderItem is undefined 的错误,所以在检查了一些 stackoverflow 帖子后发现 input.data( "autocomplete")._renderItem = function( ul, item )...
应更改为 input.data( "ui-autocomplete")._renderItem = function( ul, item )
。这解决了 _renderItem 问题,但整个组合框根本不起作用。它仅表示为一个没有任何功能的文本框。
这是代码部分
input.data( "ui-autocomplete" )._renderItem = function( ul, item )
{
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
请帮帮我,我已经被困在这个问题上 6 个小时了......
最佳答案
在此链接中查看从 1.8 到 1.9 的升级指南:
http://jqueryui.com/upgrade-guide/1.9/
您会注意到有几件事发生了变化,即:
Preparing for jQuery UI 1.10
The API redesigns deprecate a lot of functionality, which will be removed in 1.10. You don't have to wait for the 1.10.0 release in order to find out if your code will work when the 1.8 APIs are removed. You can use the $.uiBackCompat flag to test this with any 1.9 release
另一个例子:
Slider now uses ui-slider-handle-index instead of index.ui-slider-handle. Autocomplete now uses ui-autocomplete-item instead of item.autocomplete.
尝试找出 1.8 到 1.9 的主要变化并进行测试。如果这没有帮助,请再次尝试从 1.9 到 1.10,依此类推。
关于javascript - 更新后 jQuery 自动完成组合框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26790410/