JQuery UI dialog box: how can I get the dialog settings?

If I want to create a jQuery UI dialog box, I use something like:

var settings = {autoOpen:false, draggable:false, and so on...};

var dialog = $("#container").dialog(settings);

But now I want to know how I can get the dialogue settings as shown above, something like

dialog.getSettings();

I need this because I have an application that uses a lot of dialogs with default behavior. Sort of

function doAfterSubmit(dialogSettings) {
    // some code
}

var dialogSettings = {
    user:{
        add:{
            title:"Add user",
            buttons:{
                "Add":function() {
                    var settings = $(this).getSettings(); // The answer goes here

                    // AJAX to send some content

                    doAfterSubmit(settings);
                }
            },
            otherProperties
        },
        remove:{
            title:"Remove user",
            buttons:{
                "Remove":function() {
                    var settings = $(this).getSettings(); // The answer goes here

                    // AJAX to send some content

                    doAfterSubmit(settings);
                }
            },
            otherProperties
        },
        removeAll:{
            title:"Remove all user",
            buttons:{
                "Remove all":function() {
                    var settings = $(this).getSettings(); // The answer goes here

                    // AJAX to send some content

                    doAfterSubmit(settings);
                }
            },
            otherProperties
        }
    }    
}

After looking at the source of the jQuery UI dialog, I noticed a property called defaults that contains all the properties of the dialog component. But how can I get this property by default ?

Yours faithfully,

+3
source share
6 answers
dialog.dialog('option', 'name_of_option');

.

, , . ?

+7

var obj = $(selector).dialog("option");

"obj" JAVASCRIPT.

(, "" )

var obj = $(this).dialog("option");

jQuery UI 1.8.16 (). . , .

+4
// Get or set any dialog option. If no value is specified, will act as a getter.
.dialog( 'option' , optionName , [value] );
+3

dialog.options, , ( ).

+1

, - ...

var optionValue = dialog.dialog('option' , optionName);

optionName - - "height", "position", "resizable" ..

JQuery UI

EDIT: , , , , (, )

-, .dialog('option', xxxx) . , , , , . ?

+1

, "" getSettings(), .

0
source

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


All Articles