Bill F
Bill F

Reputation: 2087

capture when a user exits an xe:dialog

I need to do some clean-up when a user exits a xe:dialog. I put the code in the onUnload event like this:

viewScope.remove("vsSomeVariable");
viewScope.remove("vsAnotherVariable");
etc;

but when the userr clicks the "X" on the dialog this code does not execute. I have added some print to the console statements in my code and the onUnload does not fire when I think it should. it would appear that the sequence is onLoad, then onUnload, then the user does their thing and if they click the "X" the onUnload does not appear to execute. Is there a way to disable the "X" in the xe:dialog so I can create an "Exit" button that will do what I want, or trap the click on the "X" so that I can do my clean up process?

Upvotes: 4

Views: 143

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

Add your SSJS code to xe:dialog's onHide or onUnload event:

<xe:dialog id="dialog1">
   <xe:this.onHide><![CDATA[#{javascript:print("onHide")}]]></xe:this.onHide>
   <xe:this.onUnload><![CDATA[#{javascript:print("onUnload")}]]></xe:this.onUnload>

But, make sure you put your code into All Properties

enter image description here

and not into Events

enter image description here

Upvotes: 4

Related Questions