Not in my experience, no. But what does happen is that the
relationship set with Event.observe is a true relationship. If you
replace one element with another of the same name or ID, the
relationship is broken.
One way to work around this (if you're going to use Ajax.Updater to
replace portions of your site, and you don't want to re-declare your
listeners each time through a callback) is to observe some event on
the document or another "parent" element that you never replace. Then
look at classname or item name or id or whatever in the
Event.element() function within that observer to decide what to do
with that click.
<div id="foo">
<div id="bar">
</div>
<div id="baz">
</div>
</div>
$('foo').observe('click',function(evt){
var elm = Event.element(evt);
//elm is now a reference to the element that
//initiated the event
switch(elm.id){
case 'bar':
//do something
break;
case 'baz':
//do something else
break;
default;
break;
}
});
Now it doesn't matter at all what you do with #bar and #baz -- you can
replace them wholesale, and as long as there's something in the #foo
div with those IDs at the time that a click happens, the function will
Just Workâ˘.
Walter
On Apr 7, 2009, at 6:33 PM, BrentNicholas wrote:
> So does prototype time out, expire? Or is this some form of
> Event.observe mappings being lost when another ajax.request is made
> with new buttons (of different id names) mapped to functions with
> Event.observe?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---