JQuery UI Dialog - Cannot Delete Buttons

How to remove buttons in jquery dialog? For example, I tried to call .dialog back with the correct new parameters, but the dialog seems unaffected.

Dialogue

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

Thoughts?

+7
javascript jquery jquery-ui
source share
6 answers

Buttons cannot be added / set during dialog loading.

+2
source share

You are passing new buttons incorrectly. Parameters must be passed as an object.

This will work:

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

No need to destroy and create a new dialogue.

Of course, you can also replace the button object with a new set of buttons if you want:

 var options = { buttons: { NewButton: function () { $(this).dialog('close'); // add code here } } }; $(selector).dialog('option', options); 
+13
source share

FWIW,

 $(".dialog").dialog("option", "buttons", null); 
+4
source share

You need to destroy first first. Then you can create a new one with the new options you want.

EDIT (response to comment): I don't know what to tell you. I did the following on my website and WFM.

 $('.selector').dialog('destroy'); $('.selector').dialog({ buttons: { "Ok": function() { $(this).dialog("close"); } } }); $('.selector').dialog('open'); 

You need to return to the preliminary state to change the buttons, which makes destroy . Maybe I just wasn’t clear enough on the steps.

0
source share

The discussion here is better: http://www.nabble.com/jQuery-dialog-add-remove-button-on-the-fly-td22036498s27240.html

Add to the prescribed extensions, and you can just use addbutton and removebutton (you should switch to the natural camel :)

0
source share

Another, perhaps the easiest and most flexible way to do this is through CSS. (what if in the end they will be needed in the future ...).

Looks like:

 .ui-dialog-titlebar-close{display:none} 

If you want to do this only for some dialogs, you can add the dialogClass: parameter when initializing the dialog, and your css will look like (for example, you added myDialogClass as a dialogClass, so that the entire dialog container will be accessible through this class:

 .myDialog .ui-dialog-titlebar-close{display:none} 

Good luck setting up!

0
source share

All Articles