So I have a default dialog with 2 buttons defined. In my code, it looks the following:
var defaultButtons = [{
text: "default"
},
{
text: "default"
}
];
$(document).ready(function () {
$("#dialog-confirm-dynamic").dialog({
position: {
my: "center 10%+center",
at: null,
of: window
},
autoOpen: false,
resizable: false,
maxWidth: 250,
maxHeight: 150,
width: 250,
height: "auto",
modal: true,
buttons: defaultButtons
});
});
function showConfirm() {
document.getElementById("confirm-dyn-inner").innerHTML = "Are you sure to do this ?";
$("#dialog-confirm-dynamic").dialog({ title: "Delete" });
defaultButtons[] = [{
text: "Delete",
click: function () {
document.form.submit();
}
},
{
text: "Cancel",
click: function () {
$(this).dialog("close");
}
}
];
$("#dialog-confirm-dynamic").dialog("open");
}
In showConfirm() I'm trying to change the text and behaviour of the buttons, but I suspect that they have already been rendered and changing values of the array, even before "open" is not changing anything.
What is the best way to approach this? TIA
showConfirm()?defaultButtons[] = ...is invalid JS syntax. You shouldn't have[]there.