Some oddities with script.aculo.us
In working with Rails, I’ve started playing with some basic Javascript stuff—things I’ve long since ignored. To do that, I’m using the script.aculo.us framework that is include (along with Prototype), but running into some odd behaviors with the following example code:
<a href="#" onclick="new Effect.Appear('comment_form');">
Open comment form
</a>
<div id="comment_form"> ... </div>
Namely, nothing happens at all. Period. If instead I change the underscore (’_’) to a dash:
<a href="#" onclick="new Effect.Appear('comment-form');">
Open comment form
</a>
<div id="comment-form"> ... </div>
it starts working. This is very troubling, as I use underscores all over the place in my CSS, and have never had a problem before. Talking to someone on IRC, they use underscores all the time without problem, so I don’t understand what’s going wrong in my case. It’s 100% reproducable though.
Weird.
This entry was posted at 1:23 pm on 10 March 2006 and is filed under Ruby. You can follow any responses to this entry through the post-specific RSS 2.0 feed.
Both comments and pings are currently closed.
I think this is probably because originally in the CSS1 spec underscores were not allowed in class or ID names unless escaped
e.g. class\_name
The becamse allowed later on via an ammendement in 2.1 afair but a few browsers might still not like them despite accepting CSS.