Reputation: 1346
I have a text area that a user can type in then with a button what they typed gets displayed. When they add spaces I get in error in the JavaScript though because its all not on the same line. Is there a way I can save the text with the html formatting such as /n?
$(button).click(function(){
$(DisplayUserTextArea).html('<p> <%= @user.TextArea %> </p>');
});
This what happens when it runs on the site and its getting an error here because its spaced out.
$(button).html('<p> Test Text
TESTTTTTTT</p>');
Upvotes: 0
Views: 297
Reputation: 6531
Try
$(DisplayUserTextArea).html('<p> <%= @user.TextArea.squish %> </p>');
here is detail description remove all whitespaces and new lines.
This should work Thank you
Upvotes: 1