Updating textarea with Ajax: unterminated string literal
If you try to update a textarea with newlines in it via Ajax, you may get an “Unterminated string literal” error. The update coming back may look like this:
$('textarea_to_update').value='line one
line two
line three';
This will fail because the javascript will interpret the newline as the end of the command.
So, replace those newlines with the newline character and the textarea will get updated correctly:
textarea_value.gsub!(/\n/, '\n')

Posted by Wes in
Gavin Todes says:
thanks, just what i was looking for!