Hi, All of your subclasses and instances share a unique responders object.
Why don't you just set your responders as regular instance methods of your class ? That would be a lot cleaner and would avoid the problem completely. Best, Tobie On Feb 18, 10:36 pm, dashifen <[email protected]> wrote: > Bear with me, as the problem I'm encountering seems very arcane. > Hopefully I can describe it well enough that we can determine what the > problem is and fix it. > > A few months ago I designed an lightbox style "modal" dialog class > that I call the Dashbox. No one else really uses it but me, I wrote > it to learn more about object oriented programming within the > Prototype framework and it's served my needs to date. I've frequently > used Class.create() to produce subclasses of Dashbox that load (via > the Ajax object) specific files or have specific behaviors, etc. > > Dashbox, like any good utility class, provides me some basic > responders to which I can attach functions which create the necessary > behaviors. Two of these responders are afterOpen and afterClose. By > default, the Dashbox uses Prototype.emptyFunction for these responders > and then when a Dashbox instance is created (with the new operator), > custom functions can be attached to the the instance and are called at > appropriate moments in the life time of that instance's operation. > Custom responders are passed as an object to the constructor of an > instance and applied to the instance as follows: > > initialize: function(url, custom_responders) { > /* ... other stuff goes here ... */ > > if(custom_responders) for(responder in custom_responder) > this.responders[responder] = custom_responder[responder]; > > } > > Previously, it was always one instance of the Dashbox--or its > subclasses--on a page at a time, but today, I ran into the need to > display a date-picker dialog (called Dashdate) and some context- > sensitive help (Helpbox). Both of these classes are subclasses of > Dashbox. For a reason that I cannot determine, however, the custom > responders for the class that is instantiated _last_ become the > responders for both instances. > > Here's the relevant files: > * Dashbox:http://pastie.org/393317 <-- pastie didn't like the > line lengths in this one, sorry. > * Dashdate:http://pastie.org/393314 > * Helpbox:http://pastie.org/393316 > * The file which instantiates them: http://pastie.org/393322 > > At this point, I'm clueless. If you look in Dashdate and Helpbox, you > can see that their afterOpen handler has a Firebug console.log() > statement in it. In the code on the fourth link (the file which > instantiates them) you can see that the date picker is instantiated > last. Therefore, whether the Helpbox's activate is called or the > Datepicker instance's, the dpAfterOpen method is executed. > > I feel like I'm not explaining myself well, so I hope this isn't all > clear as mud. Feel free to ask questions cause, for the moment, I'm > completely stymied. > > Thanks, > Dave Dashifen Kees --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
