views:

97

answers:

2

Hi,

I have developed a RIA application where i have used many and many dialogs JQuery UI components. Most of it are set up according to

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

Answer: How can i set up it a global property in order to avoid set up in each dialog ?

regards,

A: 

You could store the options object in a global variable:

In global scope do:

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

And then:

$("container").dialog(DIALOG_OPTIONS);
stefanw
+1  A: 

As has been said, you could create a globally scoped variable. Alternatively, you could create your own jQuery extension that wrapped the dialog, and keep your own options in there. For instance (this is off the top of my head, so I apologise in advance if it isn't 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...
  }
}
Pete OHanlon