Jquery自动完成不追加
Jquery Auto Complete Does Not Append
Jquery新手。我的jquery追加似乎不工作。如有任何帮助,不胜感激。
我使用jquery 1.8.3版本和UI 1.9.2。
下面是我的代码。
$('.tinputer').autocomplete({
source: "http://localhost/myapp/items/search_item",
minLength: 1,
select: function(event, ui) {
var $itemrow = $(this).closest('tr');
$itemrow.find('#item_description').val(ui.item.description);
$itemrow.find('#unit_price').val(ui.item.price);
$itemrow.find('#qty').focus();
verify_item(ui.item.value);
}
}).data("autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.value + item.description + "</a>" )
.appendTo( ul );
};
小提琴- http://jsfiddle.net/Yw2Y7/1/尝试在第二行的项目框中键入。第一行正常
结果被填充,我得到下拉列表,但只显示值。item.description没有追加,或者追加部分似乎完全被忽略了。
非常感谢您的帮助
$('.tinputer').autocomplete({
source: projects,
minLength: 1,
select: function (event, ui) {
var $itemrow = $(this).closest('tr');
$itemrow.find('#item_description').val(ui.item.description);
$itemrow.find('#unit_price').val(ui.item.price);
$itemrow.find('#qty').focus();
verify_item(ui.item.value);
}
}).
each(function(){ //This is the line added.
$(this).data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.value + " - " + item.description + "</a>")
.appendTo(ul);
} }
);
http://jsfiddle.net/skhan/Yw2Y7/3/
相关文章:
- 如何在jquery中停止在更改时追加值
- JQuery.on(“keydown”)追加到页面时不工作
- jQuery[button.class]未检测到用按钮追加行
- 使用jQuery'生成输入字段;s追加
- 正在从JQuery追加Laravel Blade
- jQuery-根据值在输入字段后追加图像
- jQuery动态使用.append()添加输入,但发布表单不是追加数据
- 追加Jquery后的Binding Click事件不起作用
- 追加JQuery元素和Angular
- 如果数据不存在,则在表上追加jQuery
- 正在停止永不结束的追加.jQuery
- 问题在于克隆、拼接、删除、追加 jquery 函数
- 在 HTML 中动态追加 Jquery
- 追加 jquery 不起作用
- 无法追加 jquery
- 未追加 jQuery json 值
- 添加内容使用追加- Jquery
- 追加jQuery工作,但onclick不工作
- 不工作追加(jQuery)在代码中
- 不能向新包装的元素追加jquery元素