这是我的HTML:
<table id="tableUserPaymentTypeRight">
<col width="50%"/>
<col width="25%"/>
<col width="25%"/>
<script id="rowUserPaymentTypeRight" type="text/x-handlebars-template">
{{#each Data}}
<tr>
<td>{{FullName}}</td>
<td>
{{#if Right_Add}}
<input type="checkbox" value="{{UserID}}_0" checked/>
{{else}}
<input type="checkbox" value="{{UserID}}_0"/>
</td>
<td>
{{#if Right_Confirm}}
<input type="checkbox" value="{{UserID}}_1" checked/>
{{else}}
<input type="checkbox" value="{{UserID}}_1"/>
</td>
</tr>
{{/each}}
</script>
Run Code Online (Sandbox Code Playgroud)
这是我的js:
var userPaymentTypeRight = $('#rowUserPaymentTypeRight').html();
var userPaymentTypeRightTpl = Handlebars.compile(userPaymentTypeRight);
var context = data;
var html = userPaymentTypeRightTpl(context);
$('#tableUserPaymentTypeRight').html(html);
Run Code Online (Sandbox Code Playgroud)
像这样的数据:
{
{UserID: 26031, FullName: "Aaron Zubler", Right_Add: null, Right_Confirm:null, RowIndex: 1},
{UserID: 26390, FullName: "Achilleas Hoppas", Right_Add: null, Right_Confirm: null, RowIndex: 2},
{UserID: 26168, FullName: "Ai Ke", Right_Add: null, Right_Confirm: null, RowIndex: 3},
{UserID: 26310, FullName: "Alessandra Giordanella", Right_Add: null, Right_Confirm: null, RowIndex: 4}
}
Run Code Online (Sandbox Code Playgroud)
根据API似乎是正确的,但我得到了错误:Uncaught TypeError:Handlebars.compile不是一个函数.
什么是
console.log(Handlebars.compile)
Run Code Online (Sandbox Code Playgroud)
展示?
在 Firefox Firebug 控制台上完成,我的显示:
function(input, options)
Run Code Online (Sandbox Code Playgroud)
还有 Handlebars 的 console.dir 吗?矿:
console.dir(Handlebars)
Run Code Online (Sandbox Code Playgroud)
输出:
helpers Object { helperMissing=function(), blockHelperMissing=function(), each=function(), more...}
Run Code Online (Sandbox Code Playgroud)
....
VERSION "1.3.0"
Run Code Online (Sandbox Code Playgroud)
....
compile function(input, options)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5494 次 |
| 最近记录: |