Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters in bound knockout data model

I have a data model with special characters in it (degree signs).. so the property contains the following: "48 ° f". However, when the UI updates to this data, I see the "°", not the degree sign. I have also tried "°", but that doesn't work either.

How do I put special characters in the data model and have them appear on the UI?

like image 205
whiteatom Avatar asked Feb 16 '23 11:02

whiteatom


1 Answers

You should use html binding for this:

<span data-bind="html: test"></span>

var vm = {
    test: ko.observable("48 &deg; f")
};

ko.applyBindings(vm);

Here is a working fiddle: http://jsfiddle.net/svu82/

Read more in the KO documentation: http://knockoutjs.com/documentation/html-binding.html

like image 194
Artem Vyshniakov Avatar answered Feb 19 '23 01:02

Artem Vyshniakov