Yup. That makes sense. So what you want to do is not call
Event.observe on page load but, after the Ajax call has been completed
and the html inserted.
You may not be able to use the updater method, since you need to
coordinate the call.
Instead, use Ajax.Request and manually update the subnav with the $
('container').update(html) method. After that, THEN call
Event.Observe.
On Feb 9, 8:38 pm, anathema <[EMAIL PROTECTED]> wrote:
> Well let me give you a little better explanation.
>
> initially a page is loaded... let's say the home page. from there
> people use the main navigation. when a link is clicked i get the page
> through ajax.update with fancy fades and stuff.
>
> all is good because that nav exists on every page so the elements are
> always present. however, on one of the 'pages' that i retrieve via
> ajax there is a sub nav. so now i have all these new elements in which
> i want to do the same thing as i did the main nav. click on link and
> content is replaced.
>
> did that make sense?
>
> On Feb 9, 7:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > I'm not really sure how you're code is set up, but the most generic
> > way would be use setInterval and clearInterval when the condition is
> > met
>
> > IE
>
> > function setObservers(){
> > if( $('myLinkId') ){
> > Event.observe('myLinkId', 'onclick', myFunctionName);
> > clearInterval(timer);
> > }
>
> > }
>
> > var timer = setInterval('setObservers',100);
>
> > It's not the most elegant solution, but w/o knowing exactly what
> > you're trying to do, it's the best i can offer.
>
> > On Feb 9, 7: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?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---