Override jQueryUI dialog default options

umpirsky picture umpirsky · Feb 18, 2010 · Viewed 16.4k times · Source

I want to be able to create modal dialogs, with, for example

close: function() {
    $(this).remove();
}

default option, without need to specify those on dialog creation, but somehow override those parameters on one place.

Is this possible?

Answer

James W picture James W · Mar 5, 2010

I, too, needed to override default options and took me a while to figure out for jQuery UI 1.8:

$.extend($.ui.dialog.prototype.options, {
    modal: true,
    resizable: false,
    draggable: false
});

The above code will allow you to drop anything on top of the dialog options. The above method should work for most UI components (it will also let you prototype over the functions that exist, or add to).