JavaScript句柄栏不显示数据

时间:2013-12-30 21:42:20

标签: javascript jquery handlebars.js

我正在使用把手在html中显示一组javascript数组。

javascript数组看起来像这样

[{pid:"1mn0wZj6yN", id:"yUjCaVzZ3CcCdOj"},{pid:"uEG9LXUaZi", id:"0eamlmJAFd2Ltwd"}]

创建一个jquery get请求来获取此数组

$.get( "file.php", function( respo ) {
       var temmple = Handlebars.compile($('#template').html());
       $('#container').append(temmple(respo));      
  });

这是句柄栏模板

 <script id="template" type="text/x-handlebars-template">
          {{#each respo}}
          <p>{{id}}</p>
          {{/each}}
 </script>

输出显示在一个名为container的id的div中,但输出没有显示,也没有给出任何错误。我怎样才能解决这个问题?感谢

1 个答案:

答案 0 :(得分:0)

{{#each this}}
  <p>{{id}}</p>
{{/each}}

可能你需要的东西,除非你在传递给把手的物体里面有一个名为respo的物体。

example

相关问题