I have defined my dialog on the page load. I can see the dialog and everything seems to be fine so far:
dlg1 = $("#modalHolder");
dlg1 = dlg1.dialog({
width: 300,
height: 150,
modal: true,
autoOpen: false,
resizable: false,
closeOnEscape: false,
draggable: false,
overlay: {
backgroundColor: 'red',
opacity: 0.65
},
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});
Now I would like to set the close event dynamically, so I tried this:
function setCloseFunction(fun)
{
dlg1.dialog({
close: function(event, ui)
{
alert("2");
fun();
}
});
}
And I call it as:
setCloseFunction(new Function("alert('1')"));
However when closing the dialog, the alert never appears. Any ideas?