javascript - Rails text_area won't load via js if a newline is present -
i have comment form renders content of text area via js. works long there no new line entered in text area, when there doesn't appear once page refreshed comment appears (though without new line). get's commited database , server says js file has been rendered.
this comment.js.erb;
$('#comments').append("<div class='comment'><h4><%= @comment.body %></h4></div>");
adding escape_javascript
, html_safe
thing worked me, though still doesn't display newlines properly.
$('#comments').append("<div class='comment'><h4><%= escape_javascript(@comment.body).html_safe %></h4></div>");
Comments
Post a Comment