icanhaz/mustache loop (iterate through elements) js error

你说的曾经没有我的故事 提交于 2019-11-29 12:59:48

Finally I found the error. It was the jquery version problem - 1.9.1 was returning the error and 1.8.3 was not. Compare those demos:

for the 1.9.1 version, look at the javascript console.

Moreover, if I changed

<script id="myTemplate" type="text/html">
    {{#stuff}}
    <option value="{{key}}">{{desc}}</option>
    {{/stuff}}
</script>

to

<script id="myTemplate" type="text/html">
    {{#stuff}}<option value="{{key}}">{{desc}}</option>{{/stuff}}
</script>

for 1.9.1, it also worked fine.


edit: this is an opened issue on icanhaz/github. If you wish, please help to fix this bug!

var listOfStuff = {stuff: [ 
                  {key: "1", desc: "First"},
                  {key: "2", desc: "Second"}
              ]};
var html = ich.myTemplate(listOfStuff);
$("#mySelectBox").append($(html));

Try that?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!