PDA

View Full Version : [CLOSED] Adding a listener to BeforeDestroy event on TabPanel



supera
Mar 21, 2012, 5:44 PM
Hi!

I create the tabs of my tabPanel with the JavaScript bellow. This javascript create a new tabPanel and load in this new tabPanel a aspx page.
I wish call a directmethod in aspx page loaded in tabPanel when tabPanel was closed... I wish add a listener to BeforeDestroy event, but I know do this in JavaScript...

I think that I should add "listener.beforeDestroy.handle = ''this.getBody().App.direct.MyMethod();"... It's correct?



<script type="text/javascript">
var addTab = function (tabPanel, contextID, Title) {
var tab = tabPanel.getComponent(contextID);

if (!tab) {
tab = tabPanel.add({
id: contextID,
title: Title,
closable: true,
loader: {
url: "/app/tools/explorerweb/explorerweb.aspx?IDSistema=SGE&ContextID=" + contextID,
renderer: "frame",
loadMask: {
showMask: true,
msg: "carregando " + Title + "..."
}
}
});
}

tabPanel.setActiveTab(tab);
};
</script>

Daniil
Mar 21, 2012, 7:31 PM
Hi,

I would use the BeforeClose event. Please add the following thing into a tab config:

tab = tabPanel.add({
...
listeners : {
beforeclose : {
fn : function (tab) {
//Call DirectMethod
return false; // To get DirectMethod working, because an iframe will be destroyed.
// You can close a tab within the success/failure DirectMethod handlers.
}
}
}
});

You will also need to prevent a tab from closing returning false => to avoid a tab to be destroyed => to get DirectMethod working.

supera
Mar 22, 2012, 12:49 PM
Works fine!!!

Thanks a lot, Daniil.