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('&para;').join('</p><p>') + '</p>';


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -