javascript - Returning paragraph breaks with KnockoutJS -
i have list of comments in database returns following entries:

the comment field text includes paragraph breaks. my question is: how return these breaks inside knockout?
<p data-bind="text: comment"></p> will return
<p data-bind="text: comment">paragraph 1 paragraph 2 paragraph 3</p> i tried html binding, seems wrap html around returned value, not inside it. there way add </p> <p> between breaks without having resort <pre>?
thanks!
you use computed observable format text. here's example: http://jsfiddle.net/badsyntax/dcvzq/
i split text on paragraph character, join opening , closing <p> tags:
'<p>' + this.text().split('¶').join('</p><p>') + '</p>';
Comments
Post a Comment