JQuery UI对话框:我如何获得对话框设置?

Art*_*ald 3 settings jquery jquery-ui-dialog

如果我想创建一个JQuery UI对话框,我使用类似的东西:

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

var dialog = $("#container").dialog(settings);
Run Code Online (Sandbox Code Playgroud)

但现在我想知道我如何检索如上所示的对话框设置,例如

dialog.getSettings();
Run Code Online (Sandbox Code Playgroud)

我需要它,因为我有一个应用程序使用许多具有默认行为的对话框.就像是

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
        }
    }    
}
Run Code Online (Sandbox Code Playgroud)

在看到JQuery UI对话框源代码后,我注意到一个名为defaults的属性,它包含对话框组件的所有属性.但是我怎么能得到这个默认属性?

问候,

Dan*_*anO 7

dialog.dialog('option', 'name_of_option');
Run Code Online (Sandbox Code Playgroud)

那应该返回该对话框的选项.

你可以做的是保留名称列表并循环它们以重建设置数组.为什么你需要返回所有选项?