JSRender 条件语句
JSRender conditional statement
下面的条件(if)语句返回此浏览器错误:"未捕获的类型错误:对象46没有方法'替换'"在第463行的jsrender.js文件中(在Chrome和IE8中)
**更新 2012-06-10---抱歉,在我的原始帖子中,我简化了我的场景太多,并且错误不存在。 我已经更新了代码(如下),以更准确地表示我看到的错误。 如果从此代码中删除 {{if 1==1}} 行,它将完美运行。 在这一行完好无损的情况下,我得到上述错误。
<script id="tmpl_report_entry_table_data_rows" type="text/x-jsrender">
{{if 1==1}}
<tr class="attribute_data_row">
<td class="entry_id attribute_data"><span>{{:ENTRY_ID}}</span></td>
<td class="attribute_1 attribute_data hidden"><span>{{:ATTRIBUTE__1}}</span></td>
<td class="attribute_2 attribute_data"><span>{{:ATTRIBUTE__2}}</span></td>
<td class="attribute_14 attribute_data"><span>{{:ATTRIBUTE__14}}</span></td>
<td class="attribute_13 attribute_data"><span>{{:ATTRIBUTE__13}}</span></td>
<td class="attribute_11 attribute_date attribute_data"><span>{{:ATTRIBUTE__11}}</span></td>
<td class="attribute_11 attribute_date_hidden"><span>{{:ATTRIBUTE__11}}</span></td>
<td class="attribute_3 attribute_data"><span>{{:ATTRIBUTE__3}}</span></td>
<td class="attribute_4 attribute_data"><span>{{:ATTRIBUTE__4}}</span></td>
<td class="attribute_5 attribute_data">
<a href="?"><span>{{:ATTRIBUTE__5}}</span></a>
</td>
<td class="cmd"></td>
</tr>
{{/if }}
</script>
<script>
var obj_my_data = [
{"ENTRY_ID":79,
"test":true,
"ATTRIBUTE__1":"Aleutian Islands",
"ATTRIBUTE__2":"Arrowtooth Flounder",
"ATTRIBUTE__13":"BSAI trawl limited access",
"ATTRIBUTE__3":"Open",
"ATTRIBUTE__4":"TAC",
"ATTRIBUTE__5":"",
"ATTRIBUTE__11":",",
"ATTRIBUTE__14":"Entire GOA"},
{"ENTRY_ID":80,
"test":true,
"ATTRIBUTE__1":"Aleutian Islands",
"ATTRIBUTE__2":"Atka Macherel",
"ATTRIBUTE__13":"BSAI trawl limited access",
"ATTRIBUTE__3":"Open",
"ATTRIBUTE__4":"TAC",
"ATTRIBUTE__5":"",
"ATTRIBUTE__11":",",
"ATTRIBUTE__14":"Entire GOA"}
];
$(document).ready(function(){
$("table tbody").append($("#my_template").render(obj_my_data));
});
</script>
抱歉没有看到您的更新。结束 if 标记有额外的空格。它应该是{{/if}}
的,而不是{{/if }}
的。
相关文章:
- 这个条件语句的逻辑有问题
- 如何检查if/else语句中的随机条件
- 使用条件语句,使 jquery fadeIn/fadeOut 仅在视口 >= 480px 时才有效
- 照片滑块的条件语句
- 使用解析为javascript源的.php,如何使用条件语句将javascript代码封装在php括号之间
- KnockoutJS:为虚拟元素使用嵌套的条件if语句
- 在if语句注释的条件内指定变量的值
- Javascript/C# - 满足语句条件时的确认对话框
- 如何将窗口[VariableName]设置为if语句条件
- if 语句条件由 javascript 中 if 语句内的内容触发
- if 语句条件逻辑
- 函数声明,就像语句条件一样
- 如何减少“如果语句”条件?[减少 if 语句中的条件]
- if语句条件检查!= "undefined"失败
- If语句条件满足,但内容未执行
- AngularJS在ng-repeat语句中的if语句条件
- 变量中用作if语句条件的字符串
- Javascript如果语句条件不满足
- if 语句 - 条件评估时间(Javascript)
- 数组中指定的 if 语句条件