Michael Schuerig wrote:
> On Sunday 17 December 2006 00:01, Ryan Gahl wrote:
> > OK, just a suggestion. Sounds like you're not really working with a
> > long lived single page app anyway.
>
> Indeed, sorry I didn't explain better what I'm doing from the start. I'm
> not meaning to dismiss your suggestion either. It's just that, in my
> opinion, it appears overly complicated for applications essentially
> composed of multiple pages.
>
> Here's an idea I haven't tried and I'm not sure if it is workable.
> Methods in the Event namespace already keep track of objects and their
> attached observers. Here's a (faulty!) method that demonstrates what I
> have in mind
>
> update: function() {
> for (var i = 0, length = Event.observers.length; i < length; i++) {
> var observer = Event.observers[i];
> var element = observer[0];
> if (!Element.isInDOM(element)) {
> Event.stopObserving.apply(this, observer);
> if (element.id != '') {
> var replacement = $(element.id);
> if (replacement) {
> observer[0] = replacement;
> Event._observeAndCache(this, observer);
> }
> }
> }
> }
> }
>
> (As is, this method messes up Event.observers array.)
> A method that (correctly) implements this idea could be hooked into ajax
> requests that change the DOM.
>
> Obviously, the above method depends on some way of finding elements in
> the updated DOM that correspond to removed elements. The best I've come
> up with is using an explicit id. This won't work in the important case,
> where observers are attached to elements not based on their id, but
> based on more circumstantial conditions such as CSS selectors.
>
> Michael
>
> --
> Michael Schuerig
> mailto:[EMAIL PROTECTED]
> http://www.schuerig.de/michael/
The easiest solution I've seen for this is to
1. destroy all the observers
2. recreate them after the page is modified
_Kevin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---