I'm looking for backward reference to objects "parent" information.
Once constructor are called is there any ability to get reference to
the caller context inside this constructor ?

An sample tells much more than simple words:

var firstClass = function(){
        // How to detect, which object invoked this constructor - firstRunner
or secondRunner
        parent.firstRunnerMethod();
        parent.secondRunnerMethod();
}

var secondClass = Class.create({
        initialize: function() {
           // How to detect, which object invoked this constructor -
firstRunner or secondRunner ?
                parent.firstRunnerMethod();
                parent.secondRunnerMethod();
        }
});

var firstRunner = function(){
        var firstObject = new firstClass();
        var secondObject = new secondClass();

        this.firstRunnerMethod = function() {};
}

var secondRunner = function(){
        var firstObject = new firstClass();
        var secondObject = new secondClass();

        this.secondRunnerMethod = function() {};
}

I can solve this by adding 'this' reference as argument to object
constructor.

        var firstObject = new firstClass(this);

But this solution seems too coarse. Is there any other natural way ?

Thanks in advance !
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to