I can't work out how to update a global variable from within YUI3.
Consider the following code:
window.myVariable = 'data-one';
var yuiWrap = YUI().use('node',function(Y) {
console.log(window.myVariable); // 'data-one'
window.myVariable = 'data-two';
console.log(window.myVariable); // 'data-two'
});
console.log(window.myVariable); // 'data-one'
Can anyone explain this to me? It's causing me a lot of trouble. Why can window.myVariable be accessed but not properly updated from within a YUI3 block?
I think it might have something to do with Closures but I don't understand why Closures should apply to the global "window" object.
Help?
The callback is not fired immediately but after something happened: