On Apr 24, 2009, at 1:38 AM, katz wrote:

> On Event observers, I just realized it wasn't working because the html
> was only inserted upon calling "Add new item variation."
> So it would definitely fail regardless of whether
> document.observe('dom:loaded',function() or  
> Event.observe(window,'load',function() is used.
> That's something I didn't see earlier.
> Adding the script below the button works fine anyway.

Read up on event delegation, that can save you a lot of specific code  
(and duplication). Basically, you take advantage of the fact that  
events usually bubble up until something catches them. So observe a  
click on the document, or on some other element that's higher up the  
DOM tree than your inserted element, and even when the click hits the  
child of that element, the parent will "hear" it.

<div id="form_container">
//buncha dynamic form elements in here
<input type="button" class="copy" value="Copy" id="button_3" />
(that button could be there in source, might be added later by JS,  
doesn't matter for the following to work)

        var elm = evt.element();
                //do your copy stuff here, using DOM traversal to work out What 
copy Where
                //another behavior here


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 
For more options, visit this group at 

Reply via email to