Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textarea in backbone and underscore html decoding the content

I am using backbone.js with underscore.js

In my template I have the following textarea

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

Now the issue is if my model's MyHtml has any ascii character it html decodes it and renders it. To know exactly what i mean check this fiddle.

How do I use the above template and still prevent this ?

like image 344
Yasser Shaikh Avatar asked Dec 01 '25 07:12

Yasser Shaikh


1 Answers

Inside your UnderScore Templates use minus sign ("-") for binding value to your html field instead of equals ("=") For eg.

<textarea id="MyHtml" rows="10" cols="75" name="MyHtml"><%- MyHtml %></textarea>
like image 114
Vipresh Avatar answered Dec 04 '25 01:12

Vipresh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!