1

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!

2 Answers 2

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);
}
Sign up to request clarification or add additional context in comments.

Comments

2

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

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

2 Comments

That will work, but you should use .prop("disabled", true);
$('#pastedial').dialog('widget').find('whatever button').prop('disabled', true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.