开发者

jQuery: dialog question - change button after init

开发者 https://www.devze.com 2022-12-16 00:01 出处:网络
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:

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': fu开发者_StackOverflow社区nction() {
            myFunction();
            $(this).dialog('close');
        }
    }
});

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

thx


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

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


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

0

精彩评论

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