As I am generating the content, I know my class and IDs that are going
to be present.

See http://pastie.org/400808 and http://pastie.org/400809 for cut down
versions of my code. Don't try to understand the specifics, but look
at the general flow.

Thi


2009/2/26 Sidney <aussiealthomp...@gmail.com>:
>
> I think you have just described the solution to a problem I am
> experiencing, but I'm a bit too noob to understand quite to how to
> implement it.
>
> A basic eample (I have similar problems elsewhere): I have a div that
> gets updated by ajax. The ajax request returns a list of data rows
> with a delete button for each row. The oberserve code is also returned
> in the response because it knows the id's of the delete buttons.  I
> *think* that when the refresh occurs the old observer handlers are
> hanging around (memory is rising) and sometimes (perhaps on other
> pages) the new content is not active i.e. the returned observers
> sometimes don't take effect (that's on another page with buttons and
> droppables).
>
> Do you suggest something like: // Hope my rough psuedo code is
> understandable
>   $$('#divid.del_button').each(removeObserver('click'));
>        update the div via ajax; (on success {
>              $$('#divid.del_button').observe( .... function to figure
> out which delete button was clicked, work out correct row id, send to
> delete action..)
>
> Is this what you mean or have I got it totally wrong? If this is
> correct, it looks like an elegent design pattern that would be
> resuable:
> 1.  clear * observers in the div
> 2. update div. On success {
>    2.1   add common obervers based on class to the div e.g. $$
> ('#divname.del_btn), $$('#divname.edit_btn), $$('#divname.view_btn)  }
>
> The 2nd problem that I infered to above, is when my ajax response
> returns a droppables div, with code to attach the droppables observer,
> sometimes that does not register.  (I say "sometimes' because I have
> droppables all over the place and haven't figured where this is a
> consistent problem; sometimes they alreay exist on a page and other
> times they get added and replaced dynamically).
>
> Cheers.
>
>
> On Feb 25, 8:13 pm, Richard Quadling <rquadl...@googlemail.com> wrote:
>> 2009/2/24 david <david.brill...@gmail.com>:
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > Why not relying on event delegation to a parent contener that will not
>> > be delete or modify ??
>>
>> > btw, I thing the only problem is an excessive memory consuption. I did
>> > not say/mean memory leak !!
>> > There should not have more impact even.
>>
>> > --
>> > david
>>
>> > On 24 fév, 16:52, Richard Quadling <rquadl...@googlemail.com> wrote:
>> >> Hi.
>>
>> >> I know that I need to stop observing on elements before I destroy them
>> >> (say they are coming in via an AJAX connection).
>>
>> >> I know one way of handling this is to not actually attach events to
>> >> dynamic content, but to the container and then use the bubbling
>> >> effect.
>>
>> >> With that, the event handler for such a container may have several
>> >> different paths through the code, depending upon the event and the
>> >> element that triggered it.
>>
>> >> I suppose if the generic event handler was nothing more than a switch
>> >> board, then the functions which is attached directly could remain as
>> >> they are.
>>
>> >> Anyone know of anything else I should be aware of with this issue?
>>
>> >> Regards,
>>
>> >> Richard Quadling.
>>
>> >> --
>> >> -----
>> >> Richard Quadling
>> >> Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731
>> >> "Standing on the shoulders of some very clever giants!"
>>
>> I've put a container around the dynamic elements. This will have all
>> the event handlers attached. Most obvious really.
>>
>> Thank you.
>>
>> --
>> -----
>> Richard Quadling
>> Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731
>> "Standing on the shoulders of some very clever giants!"
>
> >
>



-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants."

--~--~---------~--~----~------------~-------~--~----~
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