在对话框关闭时,如何防止原始字段恢复焦点



我的用户不想放开键盘在输入表单上使用鼠标;因此,我需要使用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");
            }
        }]
    });

您可以在专注的字段上使用.blur()

示例:

$("#myInputID").blur(); 

最新更新