Hi.
I don't understand the behaviour and/or the logic behind these lines of code.
Here it's a working example:
function ClassWindow()
{
this.win = new Ext.Window({
//...
});
//this.win.on('beforerender', this.myCustomHandler, this.win);
//this.win.on('beforerender', this.myCustomHandler, this);
this.win.on('beforerender', myCustomHandler, this);
function myCustomHandler()
//this.myCustomHandler= function()
{
alert('OK')
}
}
Please, note the commented code.
These are combinations of what I've tried thinking they are good solutions.
I think the handler works also when I enable "this.win.on('beforerender', this.myCustomHandler, this.win);" or "this.win.on('beforerender', this.myCustomHandler, this);" in combination with "this.myCustomHandler= function()" (that is the commented lines). Gimme Some Closure! -- Object-oriented JavaScript & Ajax Callbacks :: Sep 1, 2008 //an associative array, so that event handlers can find them A closure is a variable that is local to the object scope (meaning it can't http://knol.google.com/k/glen-ford/gimme-some-closure-object-oriented/27lm3zg1hrg7v/4HOME | this is totally gonna work… » Blog Archive » Using Closures To :: Dec 14, 2005 But if, in Java, you did just pass the method (via object reflection), you’d have the same problem you do here. It _is_ an issue of scope, http://alexvollmer.com/index.php/2005/12/14/using-closures-to-support-object-oriented-ajax/HOME |
Indeed, they don't work as expected, returning me an error.
Is it a pure Javascript OO issue? Or a misunderstand of how Ext works? Or simply a scope problem?
:-/:-/:-/
Thanks in advance
It's likely a scope issue. Have you read anything from this thread (http://extjs.com/forum/showthread.php?t=6336) so that you understand scope.
Where's The Advantage In Windows Genuine Advantage?
Stocks Bounce After S&P Joins Bear Market |