1
我正在使用jQuery .focus()
方法通過asp.net中的遠程腳本來關注元素。我收到了一個關於遞歸太多的錯誤。jQuery:太多的遞歸.focus()
我在做什麼錯?
asp.net代碼:
Response.Write("<script>$('#ledger_name').focus();</script>");
HTML
<input type="text" id="account_name" name="account_name" />
JS自動完成
$("#account_name").autocomplete({
source: account_master,
minLength: 1,
minChars: 0,
width: 350,
mustMatch: 0,
selectFirst: true,
matchContains: false,
autoFocus: true,
autoFill: false,
change: function (event, ui) {
if (!ui.item) {
$(this).val('');
}
},
select: function (event, ui) {
$("#account_name").val(ui.item.label);
$("#account_name_code").val(ui.item.id);
$("#account_name_parent").val(ui.item.parent);
//$('#ledger_name').focus();
return true;
}
});
jQuery UI的
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
它給在jQuery的ui.min.js文件中的錯誤上調用$('#ledger_name').focus();
在自動完成
我猜你有更多的腳本在某個地方做了'.focus()'而你處於無限的重點環路中。也許發佈更多的代碼? – karim79
本身沒有什麼錯的腳本。這是預期的用法,沒有任何理由應該重演。如果有任何事情導致它再次發生(爲什麼你認爲它可能會幫助我們解決問題),這是因爲其他地方的代碼。 – Barney
您已將'autoFocus'設置爲該文本框上的true,因此您只需擺脫''Response.Write(「」);'代碼後面的行。 –