1

I am trying my hand with knockout.js for a single page CRUD application, on almost everything it seems better than loading partial pages in to the view with ajax, one thing I'm having trouble with though, is rendering a textarea in parsed html, instead I get all the tags <p> etc.

When I was using Razor/C# I would just use @Html.Raw(Model.Details) however now I'm using <td data-bind="text: Details"></td>.

I have tried <td>@Html.Raw(new { @data_bind="text: Details" })</td> but no luck.

What would be the best way around this?

2 Answers 2

1

If you have HTML in your viewmodel you need the html binding to display it:

The html binding causes the associated DOM element to display the HTML specified by your parameter.

Typically this is useful when values in your view model are actually strings of HTML markup that you want to render.

So your code should look like this:

<td data-bind="html: Details"></td>
Sign up to request clarification or add additional context in comments.

Comments

1

You need to use html binding for this. Look it up here in their very good documentation.

So in your html element, it should be like this.

<td data-bind="html: Details"></td>

1 Comment

Thanks, had missed the documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.