アプリ全体に jquery-ui ダイアログがたくさんあります。新しいものが必要になるたびに、次の行を書きます。
$('.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('×') }
});
あるダイアログと別のダイアログで実際に異なるのは、 キーbuttons
とtitle
キーだけです。ここで必要なのは、JQuery ダイアログのアプリケーション全体のセットアップです。
$('.another-dialog').dialog({
title: 'Another dialog',
buttons: [
{ text: 'Ok' },
{ text: 'Cancel' }
]
});
必要なすべてのハッシュキーが暗黙的に設定されています(私はそれを「デフォルト」設定と呼んでいます)。
私は、自分ですべてを設定した場所に.dialog()
コールをラップできることを知っています。.myDialog()
しかし、それを行うための本当に便利な方法があるのだろうか。
前もって感謝します!