Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: dialog question - change button after init

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

like image 567
Fuxi Avatar asked Jan 12 '10 17:01

Fuxi


2 Answers

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

dlgPrompt.dialog('option', 'buttons', {
    'Ok': function() {
        myFunction();
        $(this).dialog('close');
    }
});
like image 56
SLaks Avatar answered Nov 19 '22 05:11

SLaks


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..

like image 4
Krul Avatar answered Nov 19 '22 05:11

Krul