Using Underscore.js template within Knockout.js doesn't allow me to use "if" binding -
i want use unserscore.js template speed of code. referred following question.
using underscore template knockout using interpolate due asp.net
here working example link above,
http://jsfiddle.net/6pstz/433/
however, once include "if" binding inside template, gives me error saying "this template engine not support 'if' binding within templates ".
here example,
http://jsfiddle.net/6pstz/488/
<script type="text/html" id="peoplelist"> {{ _.each(people(), function(person) { }} <li> <b data-bind="text: person.name"></b> {{= person.age }} years old </li> {{ }) }} <!-- if binding issue --> <!-- ko if : test --> <div data-bind="text:teststring">test</div> <!-- /ko --> </script>
please check console if on chrome, there should error. guess need tweak "if" binding underscoretemplateengine, i've no idea should do.
if
binding uses knockout template engine, use underscore template instead
{{ if (test) { }} <div data-bind="text:teststring">test</div> {{ } }}
see fiddle
Comments
Post a Comment