I am trying to close a window after executing a function that is not defined in the same file as the window.
I’ll try to explain the structure of the classes involved:
there are 2 classes, Class1.js and Class2.js, in Class1.js there is defined a function function1(){} and function2(){} is defined in Class2.js
How it works:
function2 it’s called in Class1.js, openning a window and it receives as parameter function1 like:
function2(function1);
function1 it’s executed when a button is clicked on the new window, defined also in Class2.js:
var win = new Ext.Window({
id: 'win that I want to close',
.
.
.
buttons: [{
id: 'button that activates function1',
text: 'button1',
listeners: {
click: function1
},
scope: win
},
.
.
.
]
});
win.show();
In Class1.js, at function1 I try to do:
if(this.id == 'win that I want to close'){
this.close();
}
But the scope that I get is the one from the button in the new window, not the window’s scope, so I cannot close it.
I know that my explanation is quite bad, but is not easy to explain and I am totally stuck at this point.
Congratulations you if you tryied to undestand what I wrote, you are very brave! and Thank you for your help!
I have the solution:
And with that I can get the element with
Ext.getCmp(this.winid)fromClass1.