I have swarm of jquery-ui dialogs across my app. Every single 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 things that are really differ between one dialog from another are the buttons
and title
keys. What I would like to have here is an application-wide setup for JQuery dialog, so the I would only call
$('.another-dialog').dialog({
title: 'Another dialog',
buttons: [
{ text: 'Ok' },
{ text: 'Cancel' }
]
});
with all the needed hash keys implicitly set up (i'd call it — "the default" setup).
I know I can wrap .dialog()
call in, say, .myDialog()
call where I'd set everything by myself. But I wonder if there's a true, convenient way of doing that.
Thanks in advance!