我正在尝试在 jQuery UI 自动完成中显示带有标签的图像。
我陷入了错误
jquery-ui.js:6853 Uncaught TypeError: Cannot read property 'value' of undefined".
但是,在我的调查过程中,发现问题出在重写 _renderItem
函数中 - 无论我在重写的实现中做什么,我都会看到相同的错误,即使我只是通过复制来定义它来自 jQuery UI 源代码的代码。
我尝试了 jQuery UI 版本 1.10.4 1.11.4 和 1.10.2,问题仍然存在。
我认为我已经尝试了几乎所有方法,甚至制作了非常愚蠢的自动完成版本,但每次我使用 _renderItem
实现执行某些操作时,都会发生错误。
根据jQuery UI的源代码,这个错误的原因是缺少ui-autocomplete-item
数据,但我确实发送了它,所以我不知道我是什么我做错了。
最佳答案
这是针对 jQuery 1.10.2
var autoComObj = $("#id").autocomplete({
minLength : 3,
width : 590,
scroll : true,
scrollHeight : 250,
matchContains : true,
autoFill : false,
cacheLength : 1,
source:function(request,response){//some code },
select:function(event,ui){//selection code }
});
autoComObj.data("ui-autocomplete")._renderItem=function(ul, item){//custom renderItem code. }
关于javascript - 无法覆盖 jQuery UI 自动完成中的 _renderItem 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37769466/