CreateTemplate, OpenTemplate and many other Jquery dialog setups use most time the same settings but there are exceptions for the height and width.
Is it possible to pass the jquery .dialog() function sort of an array with all key/value settings so I can easily always pass this array?
$(document).ready(function () {
// I would like to setup here sort of an array with properties and values
// as basis for each click-handler
/************************* Open template ****************************/
$('#OpenTemplate').click(function (e) {
e.preventDefault();
var link = this;
$('#MyDialog').dialog({
open: function (e) { $(this).load($(link).attr('href')); },
title: link.innerHTML,
autoOpen: true,
modal: true,
show: 'fade',
hide: 'fade',
width: 250,
height: 200,
buttons:
{
"OK": function () { openTemplate($(this), $('form', this)); },
"Cancel": function () { $(this).dialog("close"); }
}
});
});
/************************* Create template ****************************/
$('#CreateTemplate').click(function (e) {
e.preventDefault();
var link = this;
$('#MyDialog').dialog({
open: function (e) { $(this).load($(link).attr('href')); },
title: link.innerHTML,
autoOpen: true,
modal: true,
show: 'fade',
hide: 'fade',
width: 250,
height: 200,
buttons:
{
"OK": function () { createTemplate($(this), $('form', this)); },
"Cancel": function () { $(this).dialog("close"); }
}
});
});
});
I would try to just doing something like this:
This object can contain all the values you know will be the same throughout all your dialog boxes. If you then want to change the height, you can alter an existing dialog by doing something like this:
If you need to add buttons to the dialogObject: