On Sun, May 23, 2010 at 2:21 PM, John Merlino <li...@ruby-forum.com> wrote:

> document.getElementById("tabs") is NULL
>  var tabListItems = document.getElementById("tabs").childNodes;
>
> I think the issue is I'm calling multiple functions on page load (and
> hence since the one page doesn't have a tabs id it doesn't know what to
> do), even though I only need one function for each of the pages. But I
> wuld like to keep this tab effect in the same file. So I don't know what
> to do.

1) check the battery in your watch; it's so not 1997 anymore. :-)

> window.onload = init;

That line looks resurrected from a seriously ancient tutorial  -- read
up on EventListeners to understand why it's a poor approach, and
how you should be invoking your functions.

2) defensive coding: you can either test first to see if there is an
    element with the ID "tabs" or you can wrap the whole thing in
    a try/catch block.

> function initProduct() {
>  var tabListItems = document.getElementById("tabs").childNodes;
    // ....
> }

3) Either way, it's strictly a JS question and has nothing to do with
    Rails.

FWIW,
-- 
Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
twitter: @hassan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to