javascript - SAPUI5: function hook when something is destroyed -


i have sapui5 panel can destroyed indirectly in various circumstances various reasons (e.g. in example, parent of parent destroyed). therefore, must use function hook coming control itself.

i tried call exit function (base on this stack overflow question , this sapui5 documentation)

var ograndparentpanel = new sap.m.panel(); var oparentpanel = new sap.m.panel(); var opanel = new sap.m.panel({     exit: function(){         alert("foobar!");     }});  oparentpanel.addcontent(opanel); ograndparentpanel.addcontent(oparentpanel); ograndparentpanel.destroy(); 

i want "foobar!" alert, not getting it.

i think confusing lifecycle methods events. lifecycle methods defined within control , control can either implement them or not. events hooks bind own functionality to.

if have panel calls event (that attach own logic to), subclass panel control. define new event in metadata , in onexit method, fire event.

if interesting in doing when user closes browser, there both window.onbeforeunload , window.onunloadthat use. unfortunately, not 100% browser independent , there not guarantee called @ all.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -