Window v4 onClose event with confirmation

Hello,

I want to put some confirmation before closing any window, if my code like this no problem at all

win1.attachEvent(“onClose”, function(){
return true;
});

but when i want to put confirmation before closing window, I don’t know how (function inside function)

win1.attachEvent(“onClose”, function(){
dhtmlx.confirm({
type: “confirm-error”,
title: “Confirmation”,
ok: “Yes”, cancel: “No”,
text: “Are you sure to close this window?”,
callback: function(result){
if (result == true) {
return true; // in this section issue
}
}
})
});

Thanks for your help…

Hello
It will be recursion: when you close, onClose is called.
You need the next:

var dhxWins; function doOnLoad() { dhxWins = new dhtmlXWindows({ viewport: {object: "winVP"}, wins: [ {id: "win", left: 20, top: 30, width: 320, height: 200, center: true} ] }); dhxWins.window("win").attachEvent("onClose", function(win) { if(win.skipMyCloseEvent) return true; dhtmlx.confirm({ text: "Do you want to close the window?", callback: function(result){ if (result == true) { win.skipMyCloseEvent = true; win.close(); } else return false; } }) }); }

Thank you very much

You are welcome!

hi admins

I have this problem which I posted. I did not see

dhxWin.window('id').skipMyCloseEvent

in any of your documentation. is this available on PRO Edition?

It is a custom flag that you need to create by yourself and switch its state in the needed window condition.

Can you clarify? “skipMyCloseEvent” I tried console.dir(appwin) where appwin is a dhtmlx window instance and I can’t find “skipMyCloseEvent” method/event.

That code comes with dhtmlx window instance right? I was confuse when you said “It is a custom flag that you need to create by yourself”. I did not write that one “skipMyCloseEvent”. sorry. I was just confused.

.close()
.isWindow()
.isParked()

above mentions can be found in your documentation while “skipMyCloseEvent” can’t be found.