How do I set global properties in a jQuery dialog?

I developed an RIA application in which I used many, many JQuery UI dialog components. Most of them are customized according to

$("container").dialog({
    modal:true,
    widht:500,
    height:400
    ... and so on
});

      

Answer. How do I set up a global property to avoid setting in every dialog?

Respectfully,

+2


source to share


2 answers


As mentioned, you can create a variable with global scope. Alternatively, you can create your own jQuery extension that terminates the dialog and save your own options. For example (it is not, but I apologize in advance if this is not 100% accurate out of the box):



$.fn.extend({
  dialogDefaults: {
    modal:true,
    width:500,
    height:400
  },
  exDialog: function(options) {
     var options = $.fn.extend(dialogDefault, options);
     // Now show the dialog...
  }
}

      

+2


source


You can store the options object in a global variable:

In the global scope:

DIALOG_OPTIONS = {
    modal:true,
    widht:500,
    height:400
//    ... and so on
};

      



And then:

$("container").dialog(DIALOG_OPTIONS);

      

+2


source







All Articles