107
rated 0 times
[
109]
[
2]
/ answers: 1 / hits: 22279
/ 13 Years ago, sun, november 27, 2011, 12:00:00
excuse the pseudo code, my actual file is much larger:/
I want to call a function (with parameters) from inside a class. However, that function should be passed to the class as a variable.
someObject = {
itWorked:function(answer){
alert(answer);
},
plugins:{
somePlugin:function(){
var callback;
this.doSomething = doSomething;
function setCallback(c){
callback = c;
}
function doSomething(){
var answer = hello;
[callback](answer); // how do I call this?
}
}
},
widgets:{
something:function(){
var doIt = new someObject();
doIt.setCallback(someObject.itWorked()); // how do I send this?
doIt.doSomething();
}
}
}
So how would I pass itWorked()
to the class?
And how would I call that itWorked(answer)
function within the class as well as passing a variable to if?
More From » class