我的用户不希望在输入表单上使用鼠标时必须松开键盘;因此,我需要使用onFocus事件向他们显示一个JQuery UI对话框。但是,当调用对话框的close();时,随着原始字段恢复焦点,该对话框将重新打开。我曾尝试在下一个输入字段显式调用focus(),但该调用被忽略。
如何防止对话框关闭时原始字段重新获得焦点?使用IE11
$("#divPayorTypes").dialog({
autoOpen: false,
height: 275,
width: 465,
top: 925,
left: 275,
modal: true,
dialogClass: "no-close",
title: "Payor Type Options",
buttons: [{
text: "Set New Payor Type",
click: function () {
var payorType = $("#ddlPayorTypes :selected").text();
var payorTypeId = $("#ddlPayorTypes").val();
$("#CCTMainForEdit_PayorType").val(payorType);
sessionStorage.setItem("CurrPayorType", payorType);
$("#CCTMainForEdit_refPayorTypeID").val(payorTypeId);
$("#CCTMainForEdit_CheckNmbr").focus();
$("#divPayorTypes").dialog("close");
}
}, {
text: "Cancel",
click: function () {
$("#CCTMainForEdit_LastName").focus();
$(this).dialog("close");
}
}]
});发布于 2017-09-20 22:33:37
您可以在关注的字段上使用.blur()
示例:
$("#myInputID").blur(); https://stackoverflow.com/questions/46324758
复制相似问题