我想就與屬性「kolonadi」Jquery自動完成後按下第二個鍵運行?
當我按在文本框的主要使用每個文本框自動完成工作,頁面提醒我「的keydown enterance」,但自動完成未運行。如果我再按一個鍵,它就可以正常工作。
我該如何修改此代碼?
這是我的動態輸入:
<input name="ctl00$MainContent$qtxt_UNVAN" type="text" id="MainContent_qtxt_UNVAN" class="textEntry2 ui-autocomplete-input" kolonadi="UNVAN" style="width:200px;" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
這是jQuery的自動完成:
$('.textEntry2').keydown(function() {
alert("keydown enterance");
var kolonadi_ = $(this).attr("kolonadi");
$(this).autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/AutoCom.asmx/GetValues") %>',
data: "{ 'word': '" + request.term + "','KullaniciIndexInGlob':'<%=KullaniciIndexInGlob %>','BaslikId':'<% =BaslikId %>','columnName':'" + kolonadi_ + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('-')[0],
val: item.split('-')[1]
}
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
$("#<%=hfCustomerId.ClientID %>").val(i.item.val);
},
minLength: 1
});
});
這個插件的文檔是[這裏](http://www.jqueryui.com/demos/autocomplete)。他們都沒有建議在keydown上應用這個widget。我會訪問該頁面並查看示例。 – 2012-01-08 22:25:38