RJS doesn't execute raw Javascript?

RJS is Ruby code that generates Javascript. So just typing out straight Javascript gets interpreted as Ruby, but if it’s just a string it gets discarded as an unused local variable.

page << “javascript” is what you want. Can we see the entirety of the RJS file?


Do you have Firebug installed? There’s probably an error in the code somewhere that’s halting execution.


Ryan Belcher wrote:

another update:

The error I'm actually getting is that cal_[id]

I don't know what your general issue is, but 'cal_[id]' is not a valid
HTML id code. They can't have a [] in them. That's why Rails emits
tags with dual identifiers; a name like 'cal_[id]', and an id like

So if you really mean an id there...

It’s very possible. I can’t remember what scoping Javascript does for different browsers, but your RJS code is executed as such:

try {
[ your code here ]
} catch {
alert("[your code here again]"); // in development mode


So you’re defining the variables in a try/catch block, which might be causing scoping issues.