5

我有一个 ASP.NET MVC 页面(注册)。在加载页面时,我在该对话框上调用带有同意不同意按钮的 Jquery 对话框。

1)。默认情况下如何将焦点设置为“同意”按钮?

2)。如何禁用右上角的X(关闭)标记?(所以我不希望用户简单地关闭该对话框)。

代码:

$("#dialog-confirm").dialog({
        closeOnEscape: false,
        autoOpen: <%= ViewData["autoOpen"] %>,
        height: 400,
        width: 550,
        modal: true,
        buttons: {
            'Disagree': function() {
                location.href = "/";
            },
            'Agree': function() {
                $(this).dialog('close');
                $(this).focus();
            }
        },
        beforeclose: function(event, ui) {
            var i = event.target.id;
            var j = 0;
        }
    });        

感谢您的回复。

谢谢

4

1 回答 1

11

我用这个:

$("#dialog-confirm").dialog({

     open: function(event, ui) {

          $(".ui-dialog-titlebar-close").hide(); // Hide the [x] button

          $(":button:contains('Ok')").focus(); // Set focus to the [Ok] button
     }

});
于 2010-05-27T15:21:04.240 回答