( kh )

Ruby on Rails: RJS Error Object Error in IE6

Posted by: khirakawa on: July 21, 2009

Are you getting an RJS error in IE6, that reads “[ Object Error ]“, followed by escaped javascript?

That’s what I was getting last night while I was creating some simple navigation tabs. It was frustrating because it worked in Firefox and Safari, but not IE6. And the error message? Object Error? What does that tell me? Nothing!

So I narrowed down my javascript code to this line:

var tab_1 = document.getElementById("first_tab");
tab_1.removeClassName("active");

This was throwing the error. But why?

Well, it turns out in order to use the Prototype method removeClassName(), the element (in this case, tab_1) must have Prototype DOM extensions.

So how do you get elements with Prototype DOM extensions? Use the dollar method my friend.

Instead of getting the element from getElementById() and then calling removeClassName(), simply do:

$("first_tab").removeClassName("active")

And voila, it works in Firefox, Safari, and IE6.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


  • None
  • dsa: you should use assert_select_rjs :chained_remove, "test" because you are using chained method or you can use in your controller page.remove "test", or

Categories

Archives

Follow

Get every new post delivered to your Inbox.