开发者

How to get the Focus on one of Buttons of JQuery Dialog on ASP.NET MVC page?

开发者 https://www.devze.com 2022-12-31 11:52 出处:网络
I have an ASP.NET MVC 开发者_开发百科page(Registration). On loading the page, i am calling Jquery Dialog with Agree and Disagree buttons on that Dialog.

I have an ASP.NET MVC 开发者_开发百科page(Registration). On loading the page, i am calling Jquery Dialog with Agree and Disagree buttons on that Dialog.

1). How to set the focus to Agree button by default?

2). How to disable the X (Close) Mark that is on Top right corner? (So that i don't want the user to close that dialog simply).

Code:

$("#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;
        }
    });        

Appreciate your responses.

Thanks


I use this:

$("#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
     }

});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号