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….
What you need is a variable defined on the outside scope that is set to
this:Thanks to closures, you can do this (err, that), even inside of a function.