MVVM bind text to get raw output

1 Answer 61 Views
MVVM
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Jay asked on 01 Mar 2023, 09:17 PM

I'm binding a span to a property on my model that ends up being populated with HTML e.g., "Word<br/>break". When it gets rendered, it is rendered just like that, so it displays the <br/> inline in the text with no effect. Is there a way to tell the binding to render it in raw form so it is displayed on two lines?

                <span id="rawSpan" data-bind="text:  rawTextDisplay"></span>

I was hoping to find some option like data-raw-text='true' but apparently my google-fu needs some work. Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 02 Mar 2023, 03:18 PM

Sure, finally found it: just needed to bind to html instead of text, e.g. 

<span id="rawSpan" data-bind="html:  rawTextDisplay"></span>

Tags
MVVM
Asked by
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or