Javascript Jquery Ui自动完成选择Ui.item未定义
我的页面上有一个自动完成功能,可以正确地获取和显示数据。 数据:Javascript Jquery Ui自动完成选择Ui.item未定义,javascript,jquery,jquery-ui,autocomplete,jquery-autocomplete,Javascript,Jquery,Jquery Ui,Autocomplete,Jquery Autocomplete,我的页面上有一个自动完成功能,可以正确地获取和显示数据。 数据:Object{custId=“CUST2”,invoiceNo=“B1”} jqueryv1.8.2分钟 jqueryui-v1.10.3 $("#invoiceNo").autocomplete({ source : function(request, response) { if($.trim($(this.element).val())==""){ retu
Object{custId=“CUST2”,invoiceNo=“B1”}
jqueryv1.8.2分钟
jqueryui-v1.10.3
$("#invoiceNo").autocomplete({
source : function(request, response) {
if($.trim($(this.element).val())==""){
return;
}
$.ui.autocomplete.prototype._renderMenu = function(ul, items) {
var self = this;
ul.append("<li><table width='100%' class='table table-condensed table-bordered' style='margin-bottom:0px;'><tr><td width='20%'><b>Invoice No</b></td><td width='20%'><b>Customer ID</b></td></tr></table></li>");
$.each(items, function(index, item) {
self._renderItem(ul, item);
});
};
$.getJSON("getInvoiceList.html", {
query : $.trim($(this.element).val()),
type:"del",
}, response).error(function(xhr, ajaxOptions, thrownError) {
});
},
open: function() {
// After menu has been opened, set width
$('.ui-menu').width(700);
},
minLength : 1,
select : function(event, ui) {
alert(ui.item);
$("#invoiceNo").val(ui.item.invoiceNo);
//setCustomerDetails(ui.item.number);
getInvoiceDetailForReturn(ui.item.invoiceNo);
return false;
},error: function (xhr, ajaxOptions, thrownError) {
$.jGrowl(xhr.responseText);
}
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $("<li></li>").data("item.autocomplete-item", item) .append("<a><table width='100%' class='table table-condensed table-hover' style='margin-bottom:0px;'><tr><td width='20%'>" + item.invoiceNo + "</td><td width='20%'>"+item.custId+"</td></tr></table></a>").appendTo(ul);
};
及
到
及
所以它没有得到ui.item对象 我自己也有过这个问题。您必须将
项。自动完成项
替换为ui自动完成项
因此,仅取代码块的最后3行,这将成为:
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $("<li></li>").data("ui-autocomplete-item", item) .append("<a><table width='100%' class='table table-condensed table-hover' style='margin-bottom:0px;'><tr><td width='20%'>" + item.invoiceNo + "</td><td width='20%'>"+item.custId+"</td></tr></table></a>").appendTo(ul);
};
数据(“ui自动完成”)。\u renderItem=函数(ul,项){
return$(“”).data(“ui自动完成项”,item)。append(“.我自己在什么时候遇到过这个问题。您必须将
项.autocomplete项
替换为ui自动完成项
)
因此,仅取代码块的最后3行,这将成为:
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $("<li></li>").data("ui-autocomplete-item", item) .append("<a><table width='100%' class='table table-condensed table-hover' style='margin-bottom:0px;'><tr><td width='20%'>" + item.invoiceNo + "</td><td width='20%'>"+item.custId+"</td></tr></table></a>").appendTo(ul);
};
数据(“ui自动完成”)。\u renderItem=函数(ul,项){
返回$(“”)数据(“ui自动完成项”,项)。追加(“.我不明白你的问题。到底是什么问题?@Sébastien ui.itemundefined@S当我使用jquery-ui-1.9.2 autocomplete时,Select中的ébastien警报未定义Hello@Sébastien Bro正常工作。但如果我打开对话框,请在关闭对话框后创建两个ui小部件覆盖div一个ui小部件覆盖div移除,但剩下一个。意思是我的问题是,如果我的对话框属性Modal为True,那么关闭对话框后无法删除Modal属性false。我不理解你的问题。到底是什么问题?@Sébastien ui.item为undefined@S当我使用jquery-ui-1.9.2自动完成时,Select中的ébastien警报是UnfinedHello@Sébastien Bro。但是如果我是en dialog在关闭对话框后创建两个ui小部件覆盖div一个ui小部件覆盖div删除,但还有一个。这意味着我的问题是,如果我的对话框属性Modal为True,则关闭对话框后无法删除Modal属性false。在我的页面中,仅在一个自动完成中添加ui自动完成,因此它现在无法工作fantanstic working谢谢@SebastienIn My Page仅在一个自动完成中添加ui autocomplete,因此它现在不工作Fantantic正在工作谢谢@Sebastien
data("ui-autocomplete" )._renderItem = function( ul, item ) {
.data( "item.autocomplete-item", item )
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $("<li></li>").data("ui-autocomplete-item", item) .append("<a><table width='100%' class='table table-condensed table-hover' style='margin-bottom:0px;'><tr><td width='20%'>" + item.invoiceNo + "</td><td width='20%'>"+item.custId+"</td></tr></table></a>").appendTo(ul);
};