this was helpful for me. I didn’t get the double backslash (escape)
point yesterday.
Regards
Ingo
Where is your RJS being loaded up?
Your escaping is a off with the newlines, so that could be the issue.
When you use #<<, you’ll be dumping a string directly to javascript,
and ruby’s quoting is getting in the way, so “$(‘article_body’).value
+= ‘\n\blah\n’” would be sent to your browser as:
"$(‘article_body’).value += ’
\blah
’
Instead you should escape the newlines. Also, you’ll need to double
escape the \ before the b, because ‘\b’ will get interpreted in
javascript as a backspace character: “$(‘article_body’).value += ‘\n\
\blah\n’”. Or you can use ruby single quotes and heredocs to make
things look nicer although you won’t be able to insert variables into
the string block.
page << <<-‘end’
$(‘article_body’).value += ‘\n\blah\n’;
end
Your escaping is a off with the newlines, so that could be the issue.
When you use #<<, you’ll be dumping a string directly to javascript,
and ruby’s quoting is getting in the way, so “$(‘article_body’).value
+= ‘\n\blah\n’” would be sent to your browser as:
"$(‘article_body’).value += ’
\blah
’
Instead you should escape the newlines. Also, you’ll need to double
escape the \ before the b, because ‘\b’ will get interpreted in
javascript as a backspace character: “$(‘article_body’).value += ‘\n\
\blah\n’”. Or you can use ruby single quotes and heredocs to make
things look nicer although you won’t be able to insert variables into
the string block.
page << <<-‘end’
$(‘article_body’).value += ‘\n\blah\n’;
end
this was helpful for me. I didn’t get the double backslash (escape)
point yesterday.
Regards
Ingo
Where is your RJS being loaded up?
Your escaping is a off with the newlines, so that could be the issue.
When you use #<<, you’ll be dumping a string directly to javascript,
and ruby’s quoting is getting in the way, so “$(‘article_body’).value
+= ‘\n\blah\n’” would be sent to your browser as:
"$(‘article_body’).value += ’
\blah
’
Instead you should escape the newlines. Also, you’ll need to double
escape the \ before the b, because ‘\b’ will get interpreted in
javascript as a backspace character: “$(‘article_body’).value += ‘\n\
\blah\n’”. Or you can use ruby single quotes and heredocs to make
things look nicer although you won’t be able to insert variables into
the string block.
page << <<-‘end’
$(‘article_body’).value += ‘\n\blah\n’;
end