On Feb 9, 2008 10:22 PM, anathema <[EMAIL PROTECTED]> wrote:

>
> Newbie alert!
>
> So let's I have this in my javascript
>
> Event.observe('myLinkId', 'onclick', myFunctionName);
>
> or even
>
> $('myDivID').hide
>
> what if they don't exist yet? For example i am pulling in content via
> ajax.updater so some of my elements do not exist when the javascript
> is loaded. So all my javascript fails and the page does not function
> because it looks for those elements and does not find them.
>
> So do i handle this?


first off you should be using dom level 2 events; so onclick should be
click.
second, if the element w/ id, myLinkId, doesnt exist until its placed in the
dom by Ajax.Updater, then simply include it in a script tag in the response
from the server,
<script>
Event.observe('myLinkId', 'click', myFunctionName);
</script>
then set evalScripts:true in the Ajax.Options when you instantiate
Ajax.Updater
and you should be good to go ;)

-nathan

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

Reply via email to