I’m working on a project with Mootools 1.2 where I have 2 objects. Object A creates object B, which later on needs to pass a return value back to object A. I’ve got this working at the moment as below:
[CODE]
var objectA = new Class({
initialize: function()
{
var child = new objectB(this, ‘getReturnValue’);
},
getReturnValue: function(val)
{
alert(val);
}
});
var objectB = new Class({
this.returnObj,
this.returnFn,
initialize: function(returnObj, returnFn)
{
this.returnObj = returnObj;
this.returnFn = returnFn;
},
doSomething: function(returnVal)
{
var evalStr = ‘this.returnObj.’ + this.returnFn + ‘(‘ + returnVal + ‘);’;
eval(evalStr);
},
});
Is there another and better way of doing this, e.g. without using eval()?