我的项目中有一项要求,即为最近在Google上应用的文本框提供自动完成功能。我需要获取每个按键的数据,所以我在按键上调用了一个jQuery函数。问题是自动完成功能会在鼠标单击文本框时触发,而不是按键。我会附上代码段为更好地了解哪些是这样jQuery自动完成插件问题
$(document).keypress(function(){
lastKey = String.fromCharCode(window.event.keyCode);
alert('lastKey :: ' + lastKey);
var txtVal = document.frm.selectedTechParamName.value + lastKey;
alert('txtVal :: ' + txtVal);
$("#suggestTechParamName").autocomplete('/AEA-Authoring/TechnicianParameterAutocomplete?userAction=getTechParamsForSvcLvlDataID&txtVal=' + txtVal, {
matchContains: true,
minChars: 0,
cacheLength:0,
maxItemsToShow:10
});
});
现在,当按下任意键警报工作正常,但发生了什么事是问题的功能下半年即
$("#suggestTechParamName").autocomplete('/AEA-Authoring/TechnicianParameterAutocomplete?userAction=getTechParamsForSvcLvlDataID&txtVal=' + txtVal, {
matchContains: true,
minChars: 0,
cacheLength:0,
maxItemsToShow:10
});
当我们点击文本框时被调用。同样,你可以看到我写的属性“cacheLength:0”,因为我不希望自动完成来缓存任何数据,但这看起来似乎不起作用。任何快速回复,将不胜感激。
嗨 - 你可以编辑你的问题来标记你的代码作为代码,所以它不那么headachy? – karim79 2009-06-05 09:09:50