Oh yeah, if you replace "myDiv" with an Ajax call, you lose the event
handler and will need to call init() again upon completion.

On Mar 12, 5:00 pm, Diodeus <[email protected]> wrote:
> This should get you started:
>
> document.observe("dom:loaded", function() {
>     init()
>
> });
>
> function init() {
>   if($('myDiv')) {
>    $('myDiv').observe('click', doSomething)
>   }
>
> }
>
> function doSomething(evt) {
>     var element = Event.element(evt);
>     alert(element.innerHTML)
>
> }
>
> On Mar 12, 10:53 am, bill <[email protected]> wrote:
>
> > I want to set an observer in a html fragment loaded into a div.
> > I know I can't execute the code  to set up the observer until the new
> > code is loaded into the dom but need an example of how to use the
> > dom:loaded event to set the handler
>
> > --
> > Bill Drescher
> > william {at} TechServSys {dot} com
>
>

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

Reply via email to