自动完成功能:
<script type="text/javascript">
$(document).ready(function () {
$("#<%=NALkTxt.ClientID %>").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/WebService.asmx/GetLookUp") %>',
data: "{ 'prefix': '" + request.term + "'}",
dataType: "json",
type: "POST",
scroll: true,
scrollHeight: 180,
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) {
$("#<%=CmbHdn.ClientID %>").val(i.item.val);
},
minLength: 1
});
});
</script>
以上功能正在处理页面加载,但在任何按钮点击或事件触发后,它都无法正常工作。