Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI dialog - unable to remove buttons

How do I remove the buttons in a jquery dialog? Per example, I tried re-calling .dialog with the correct new options, but the dialog seems unaffected.

$('.selector').dialog('option', 'buttons', {} ); does not work, and nor does it work if actual new button strings and functions are declared.

Thoughts?

like image 832
Stefan Kendall Avatar asked Jul 15 '09 17:07

Stefan Kendall


3 Answers

You are passing new buttons set in a wrong way. Options should be passed as an object.

This will work:

var options = {
    buttons: {}
};
$(selector).dialog('option', options);

No need to destroy and create new dialog.

Of course you can also replace buttons object with a new set of buttons if you wish:

var options = {
    buttons: {
        NewButton: function () {
            $(this).dialog('close');
            // add code here
        }
    }
};
$(selector).dialog('option', options);
like image 160
RaYell Avatar answered Sep 24 '22 07:09

RaYell


FWIW,

$(".dialog").dialog("option", "buttons", null);
like image 37
rapi Avatar answered Sep 26 '22 07:09

rapi


Buttons cannot be added/set while the dialog is loading.

like image 30
Stefan Kendall Avatar answered Sep 22 '22 07:09

Stefan Kendall