I have a module
something = {
value : "",
anotherVal : "",
method : function(){
this.anotherVal = "I think it is accessable here";
GLOBAL.action(
func : function(){
// In here I want to access the above value.
// Which is a property of the outer something module.
<![magicOccursHere]!>.value = "magically access outer scope"
});
}
}
As you can see from the above code I would like to access a property on a level of scope outside of this by using some magicaOccursHere...
I have done this before by making the module return a function not a json object and then naming each level. But I dislike this syntax.
SOMETHING = new Something();
something = function Something() {
var bigDaddy = this;
this.value = "";
this.anotherVal = "";
this.method = function(){
bigdaddy.anotherVal = "Set one of big daddies vars";
GLOBAL.action(
func : function(){
// In here I want to access the above value.
// Which is a property of the outer something module.
bigdaddy.value = "can still set one of big daddies vars"
});
}
}
I may be completely missing the point here and if you would like to point me to it, then I would be only too happy to read.
Am I being too harsh on the messy pattern and code of option 2?