How to update changed buttons in jQuery interface dialog?

I have a jQuery UI dialog that is initialized

$('#jqDialog').dialog({
  autoOpen: false,
  modal: true,
  resizable: false,
  buttons: { 'Ok': function () { $(this).dialog('close'); } },
});

and then I want to change the buttons programmatically without reinitializing the plugin instance.

$('#jqDialog')
  .dialog('options',
  { 
    buttons: {
      'Ok': function () {
        $(this).dialog('close');
        store(id);
      },
      'Cancel': function () { $(this).dialog('close'); }
    }
  })
  .dialog('open');

When the dialog box opens, it still has the original button. With the Button plugin, you must call .button ("refresh"). Is there a similar method that needs to be called using the Dialog plugin?

+3
source share
3 answers

Why do you need customization, method name 'option'(no s):

.dialog('option',

This works even when the dialog is open, you can check here .

+2

- options option,

$("jqDialog").dialog("option", "buttons", 
    { 
        "Ok": function() { 
            $(this).dialog("close"); 
        } 
    });
0

First, you can destroy the dialog by calling $ dlg.dialog ('destory'). and overestimate the required dialogue.

0
source

Source: https://habr.com/ru/post/1777138/


All Articles