在jquery中聚焦对话框上的任何按钮

时间:2014-11-25 07:04:07

标签: javascript jquery

当用户点击任何按钮时,我打开了一个对话框。我想突出显示任何按钮或总显示对话框,用户可以直接使用ESC键关闭对话框而无需在键盘上使用TAB键。

$(function() {
    $('#messageDialog').dialog("destroy");
    $("#messageDialog" ).dialog({
        title: localProperties['exportTo'] + " " + currentURI.substr(currentURI.length - 3),
        resizable: false,
        height:250,
        width:500,
        modal: false,
        buttons: {
            "Stay on current page": {
                text: localProperties['stayButtonText'],
                id: "stay_on_current_page",
                click: function() {
                    $( this ).dialog( "close" );
                },
            },
            "Go to result page now": {
                text: localProperties['gotoButtonText'],
                id: "goto_result_page",
                click: function() {
                    $( this ).dialog( "close" );
                    goToExportResults();
                }
            },
            "Download now" : {
                text: localProperties['downloadNowButtonText'],
                id: "download_now",
                click: function() {
                    $( this ).dialog( "close" );
                    downloadPdf();
                }
            }
        },
        open: function () {
          //  $("#stay_on_current_page").focus();
            // $(this).parent().find('button:contains("Stay on current page")').focus();
            $(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
        }
    });
});
var resetMessageDialog = document.getElementById("messageDialog");
resetMessageDialog.innerHTML = "<p align = center> <img src=images/loader.gif align=center width=25/> </p>";
resetMessageDialog.innerHTML = resetMessageDialog.innerHTML + "<p align = center> <font size=2> <b>" + localProperties['inProgress'] +"</b></font></p>";
resetMessageDialog.innerHTML = resetMessageDialog.innerHTML + "<p align = center> " + localProperties['completedInfo'] + " </p>";
resetMessageDialog.innerHTML = resetMessageDialog.innerHTML + "<p align = center><b> " + localProperties['exportLocation'] + " </b> " + localProperties['completedInfoEnd'] + " </p>";

我尝试了上述方法,但也没有工作。

感谢您的帮助。

0 个答案:

没有答案