22

i've defined a dialog with 2 buttons: ok + cancel. what i want to do now is change the ok button's function after initialization, so i tried:

dlgPrompt.dialog({
    buttons: {
        'Ok': function() {
            myFunction();
            $(this).dialog('close');
        }
    }
});

unfortunately it doesnt work (when clicking ok, nothing happens). anyone knows whats wrong?

thx

2 Answers 2

40

You need to call the 'option' method, like this:

dlgPrompt.dialog('option', 'buttons', {
    'Ok': function() {
        myFunction();
        $(this).dialog('close');
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

Still works with 3.2.1...and the preferred method of modifying the dialog buttons after init
4
dlgPrompt.parent().find(".ui-dialog-buttonset .ui-button-text:eq(0)").text("FirstButton");
dlgPrompt.parent().find(".ui-dialog-buttonset .ui-button-text:eq(1)").text("SecondButton");

etc..

1 Comment

long way around but doable....i would definitely not suggest anyone do this, unless they had consumed all other alternatives.

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.