Reputation: 1395
Is it possible to send a set of common options:
var commonVars = {
autoOpen: false,
draggable: false,
resizable: false,
show: 'fade',
hide: 'fade'
};
To dialog boxes:
$('#dialog_1').dialog({
//Common vars go here somehow
width: 275,
height: 170,
dialogClass: "class1 class2"
});
$('#dialog_2').dialog({
//Common vars go here somehow
width: 600,
height: 350,
dialogClass: "class3 class4"
});
Upvotes: 4
Views: 1334
Reputation: 1395
Figured it out, kind of on accident. So for anyone wondering the same thing, you can put the commonVars
variable before each dialog's options bracket:
var commonVars = {
autoOpen: false,
draggable: false,
resizable: false,
show: 'fade',
hide: 'fade'
};
$('#dialog_1').dialog(commonVars,{
width: 275,
height: 170,
dialogClass: "class1 class2"
});
Upvotes: 1
Reputation: 30002
Example:
var object1 = {
//Common vars go here somehow
width: 275,
height: 170,
dialogClass: "class1 class2"
};
var object2 = {
//Common vars go here somehow
width: 600,
height: 350,
dialogClass: "class3 class4"
}
var commonVars = {
autoOpen: false,
draggable: false,
resizable: false,
show: 'fade',
hide: 'fade'
};
$.extend(object1, commonVars);
$.extend(object2, commonVars);
$('#dialog_1').dialog(object1);
$('#dialog_2').dialog(object2);
Upvotes: 5