I have a jQuery modal where I want to add an additional button if a conditional statement is met.
Original sample code (cutdown):
$("#dialog").html("<div></div>").dialog({
title: "Some Title",
modal: true,
width: 550,
buttons: {
Ok: function() {
//
},
'A Button': function() {
//
}
}
}).dialog('open');
So as you see above there is a modal with 2 buttons, but I also want to add in there some dynamic code to be able to cater for an additional button if a variable is set. e.g.
var some_variable = 0;
$("#dialog").html("<div></div>").dialog({
title: "Some Title",
modal: true,
width: 550,
buttons: {
Ok: function() {
//
},
'A Button': function() {
//
}
/* ??? */
if (some_variable==1) //then add the other button's code here..
/* ??? */
}
}).dialog('open');