最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable buttons in Jquery UI dialog? - Stack Overflow

programmeradmin1浏览0评论

I use a jQuery UI dialog that is made from HTML supplied from server. Code:

 $("<div id='pastedial'>" + result.htmlPasteDialog + "</div>").dialog({
                maxHeight: "85%",
                minWidth: 700,
                modal: true,
                buttons: {
                    Cancel: function () {
                        // do cancel
                    },
                    "Paste!": function () { 
                       // do action
                    }
                // some other config

            });
        }

To dialog elements I attach event handler that validates the dialog. This works well. The validation function is just another function of page, that addresses dialog items based on their IDs that I know directly.

How I can address dialog's buttons from external function (that belongs to page) so I can disable actions if dialog is not validated?

Thanks in advance!

I use a jQuery UI dialog that is made from HTML supplied from server. Code:

 $("<div id='pastedial'>" + result.htmlPasteDialog + "</div>").dialog({
                maxHeight: "85%",
                minWidth: 700,
                modal: true,
                buttons: {
                    Cancel: function () {
                        // do cancel
                    },
                    "Paste!": function () { 
                       // do action
                    }
                // some other config

            });
        }

To dialog elements I attach event handler that validates the dialog. This works well. The validation function is just another function of page, that addresses dialog items based on their IDs that I know directly.

How I can address dialog's buttons from external function (that belongs to page) so I can disable actions if dialog is not validated?

Thanks in advance!

Share Improve this question asked Nov 26, 2013 at 13:43 onkamionkami 9,44120 gold badges105 silver badges200 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

I use this, which is almost the same as Babblo, but searching for the caption of the button instead. Hope it helps.

function test() {
    $("#pastedial")
        .next(".ui-dialog-buttonpane")
        .find("button:contains('Paste!')")
        .button("option", "disabled", true);
}

You can access and disable the buttons with something like this:

function xxx(){
  $('#pastedial').find('.ui-dialog-buttonpane button:eq(1)').attr('disabled','disabled');
}
发布评论

评论列表(0)

  1. 暂无评论