I have a swarm of jquery-ui dialogs in my application. Every time I need a new one, I write the following lines:
$('.another-dialog').dialog({ title: 'Another dialog', autoOpen: false, draggable: true, modal: true, show: 'fade', hide: 'fade', width: 400, position: ['center', 'center'], buttons: [ { text: 'Ok' }, { text: 'Cancel' } ], open: function(event, ui) { $(".ui-dialog-titlebar-close span").html('Γ') } });
The only thing that really differs between one dialog from another is the buttons and title . What I would like to have here is a system-wide setting for the jQuery dialog, so I would only name
$('.another-dialog').dialog({ title: 'Another dialog', buttons: [ { text: 'Ok' }, { text: 'Cancel' } ] });
with all the necessary hash keys implicitly configured (I would call this the "default setting").
I know that I can enclose a .dialog() call, say, .myDialog() , where I myself would put everything. But I wonder if there is a correct, convenient way to do this.
Thanks in advance!
gmile source share