onBeforeClose or similar?
|
|
Hello… im testing the window object and is awesome !! but i have this question… Is there a way to control the closing of a window? Let’say that if a user clicks on the close button, then a confirm box will show asking if they truly want to close it or keep it, and then fires the selected event. Any guidance on this one please? Thanks!!! |
|
|
Just an update. I tried this: win.observe(“destroyed”, function() { if(confirm(“are you sure you want to close this window?”)){ event.continueProcess(); } else { this.show(); } }); And it works, if i select Cancel in the confirm, it shows the window back with internal functionality Ok, but, the problem is that the window controls dont work(minimize, maximize and close). Any suggestion on this? Thanks! |
|
|
Observing destroyed is too late. You need to set a custom close callback to do it.
UI.Window.addMethods({
your_close_function: function() {
if(confirm(“are you sure you want to close this window?”))
this.destroy()
}
});
new UI.Window({close: your_close_function});
|
|
|
Thanks!! That gave an idea on how to do it, but i tried like that and didnt worked, but it worked in this way:
var win = new UI.Window({
theme: "leopard",
width: 300,
height: 350,
top: $j('body').scrollTop() + 25+ chat.position,
left: Position.GetWindowSize().width/2 - chat.ancho/2 + chat.position,
id:"win_"+folio,
shadow:true,
resizable: true,
draggable:true,
close:function(){
stId = this.id;
var nickname = "";
inId = stId.indexOf("_") + 1;
idFolio = stId.substring(inId,10);
for (i=0;i<chat.usrConv.length;i++){
if(chat.usrConv[i][0] == idFolio){
nickname = chat.usrConv[i][1];
}
}
Worked like a charm :) Regards! |