Vishal Abru wrote:
I have been pulling my hair out for way too long on this...and it seems
so trivial! The following does not work:
if page['test'].className == "whatever"
page['test'].className = "whatever2"
Now that I write this post, I realize why it doesn't work - className is
access the className value in the IF statement?
Yeah, there's a fundamental misunderstanding going on here. When you
write an RJS template, you're not writing Ruby that communicates 'live'
to the web browser, where it is run.
Therefore, you cannot do anything in RJS that involves 'reading'
something about the state of the browser or document. Or in other
words, the entire RJS template has to make sense without any knowledge
of what's going on in the browser/document.