Textarea in spine and html underline decoding content

I am using backbone.js with underscore.js

In my template I have the following textbox

<textarea id="MyHtml" rows="10" cols="75" name="MyHtml"><%= MyHtml %></textarea>

      

Now the problem is my model MyHtml

has any ascii character that html decodes and processes. To know exactly what I mean, check the fiddle .

How do I use the above pattern and still discourage it?

+3


source to share


2 answers


Inside the UnderScore templates, use the minus sign ("-") to bind the value to your html field instead of equals ("=") For example,



<textarea id="MyHtml" rows="10" cols="75" name="MyHtml"><%- MyHtml %></textarea>

      

+5


source


You can insert escaped values ​​via <%- … %>

See http://underscorejs.org/#template

You write



<textarea id="MyHtml" rows="10" cols="75" name="MyHtml"><%- MyHtml %></textarea>

      

And demo http://jsfiddle.net/nikoshr/7wxrbkw8/

+3


source







All Articles