JS Anonymous Scope...

Posted by Simon on Stack Overflow See other posts from Stack Overflow or by Simon
Published on 2010-05-03T22:55:07Z Indexed on 2010/05/03 22:58 UTC
Read the original article Hit count: 431

this
Application.EventManager.on('Click', function(args) { // event listener, args is JSON
    TestAction.getContents(args.node.id, function(result, e) { 
        console.log(result);
        this.add({
            title: args.node.id,
            html: result
        }).show();
    });
});

I'm really struggling with scope and anonymous functions... I want this (on the 1st line) to be the same object as this (on the 5th line)... .call() and .apply() seemed to be the right sort of idea but I don't want to trigger the event... just change it's scope....

For a bit of contexts... the this in question is a TabContainer and TestAction is a RPC that returns content...

Thanks....

© Stack Overflow or respective owner

Related posts about extjs

Related posts about extjs-events