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?
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
'cal__id'.