使用_renderItem一种断裂自动完成场 [英] Using _renderItem kind of breaks autocomplete field
问题描述
我有一个已经工作正常,到现在为止一个jQuery自动完成场。我决定,因为我想用一些HTML结果中使用 _renderItem
就可以了。这里是我的code:
I have a jQuery autocomplete field that's been working fine up until now. I decided to use _renderItem
on it because I wanted to use some HTML in the results. Here's my code:
function prepareClientField() {
var renderItemFunction = function(ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append(item.label)
.appendTo(ul);
};
$("#client_name").autocomplete({
source: clientNames,
delay: 0
}).data("autocomplete")._renderItem = renderItemFunction;
$("#client_name").focus();
}
对于原因,现在,我不能在我的自动完成字段中使用上/下箭头。我甚至不能使用鼠标在结果中点击一个项目。有没有别的东西,我需要做,使这个实际工作?
For reason, now, I can't use the up/down arrows in my autocomplete field. I can't even use the mouse to click an item in the results. Is there something else I need to do to make this actually work?
推荐答案
的自动完成
插件在很大程度上依赖于菜单
插件,它使用 A
元素内部。从而消除了从每个项目
元素打破了菜单
插件。
The autocomplete
plugin relies heavily on the menu
plugin which uses a
elements internally. thus removing the a
element from each item breaks the menu
plugin.
您既可以在菜单
插件及功放手动BUCHER起来;设法得到它工作,或者你需要找到另一种解决方案,其中的项目有一个 A
标记,但不要弄乱你的风格。
You can either manually bucher up the menu
plugin & try to get it to work, or you need to find another solution where the items have a a
tag, but don't mess up your styles.
这篇关于使用_renderItem一种断裂自动完成场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!