PDA

View Full Version : Destroy a syncRequire js



Steve88
10 Feb 2012, 1:42 AM
Hi all.
I'm a new member and Extjs is fantastic!! :))

I have a question about a syncRequire js...
After a button click, i istanciate a js file with the syncRequire.
Ok it work very well!! It open a window with 2 buttons.
My problem is:
I need to 'destroy' the required js in the beforeclose event.
What event i should use?
Ext.destroy('MyApp.views.MyGeo.MyGeojs') not work :(

Thank you all! :)


Ext.define('MyApp.views.MyGeo.MyGeojs', {
extend : 'Ext.Window',
height : 300,
width : 600,
border : false,
layout : {
type : 'hbox'
},
initComponent : function() {
this.items = this.buildItems();
this.callParent();
},
listeners :
{
beforeclose : function()
{
//Here i need to destroy the required 'MyApp.views.MyGeo.MyGeojs'
}
},
buildItems : function() {
return [
{
xtype: 'button',
width: 380,
text: 'Button 1',
handler: function(){
alert('Button 1 pressed!');
}
},
{
xtype: 'button',
width: 220,
text: 'Button 2',
handler: function(){
alert('Button 2 pressed!');
}
}
];
}

});

mitchellsimoens
10 Feb 2012, 4:32 AM
You shouldn't use listeners like that (http://mitchellsimoens.com/?p=59)

Instead use on() within the initComponent.

Steve88
10 Feb 2012, 5:59 AM
You shouldn't use listeners like that (http://mitchellsimoens.com/?p=59)

Instead use on() within the initComponent.
Thank you for the advice! :)
Now i know how to implement the events on a Ext.define :))
Thanks :)

Is possible to 'destroy' the js loaded dynamically?

mitchellsimoens
10 Feb 2012, 6:04 AM
Just clear the namespace. Want to "unload" Ext JS then you should be able to do


Ext = null;

Steve88
10 Feb 2012, 6:14 AM
Just clear the namespace. Want to "unload" Ext JS then you should be able to do


Ext = null;
Ok, and if i need to unload particular js (for example: example.js)? Is possible?

mitchellsimoens
10 Feb 2012, 6:19 AM
If you can get the <script> tag then you can destroy it but you will still need to set the namespace to null or delete it

Steve88
10 Feb 2012, 6:21 AM
If you can get the <script> tag then you can destroy it but you will still need to set the namespace to null or delete it
Ok!! Thank you for the help! :)