In Example 1-1, text was data-bound to a
span tag. Like text, it’s quite common to data-bind content that contains HTML data.
In Example 2-1, the
getName function is expanded to wrap the output of the
name data binding with some HTML code.
HTML bindings work similarly to text with the exception that they render any HTML tags provided. If you were to use the
text binding with HTML content, the HTML would be escaped, and the content would be displayed as text.
In Example 2-1, I update two things. First, the
data-bind attribute is moved from the
span tag to the
h1 tag. Second, it is bound to the
getName function, which has been updated to contain some HTML code.
<title>Data Binding with KnockoutJS
Knockout can bind almost ...