【发布时间】:2011-05-07 01:28:08
【问题描述】:
我正在使用 jQuery 模板构建页面,但在 IE 8 中出现了一些不一致的行为。
我在 {{each}} 标记内有一个复选框元素,但是当我尝试将字符串附加到 id 时,IE 会引发错误。
这是 HTML 片段:
<script id="filters-template" type="text/template">
<div id="CoinsuranceFilters" class="filters">
<h4><label><input type="checkbox" id="checkall_coinsurance" onclick="checkClass(this, 'coinsurance_items');" class="checkall" /> Coinsurance</label></h4>
{{each Coinsurance}}
<div class="filteritem">
<label><input type="checkbox" id="${'Coinsurance_' + id}" {{if IsSelected}} checked{{/if}} class="coinsurance_items"/> ${ItemText}</label>
</div>
{{/each}}
</div>
</script>
IE 报告:“id”未定义
如果我将 id 字段更改为 id="${id}" 错误就会消失(尽管它似乎会为每 1 个复选框呈现 2 个复选框)。
这在 Chrome 和 FF 4 中没有问题
此页面使用 jquery 1.5.2 & jquery-ui 1.8.12
这是传入模板的 JSON 对象:
{
"IndividualQuoteID": "539b9d05-0c78-4c27-b238-9edaaabfb389",
"Coinsurance": [
{
"id": 267,
"ID": 267,
"IsSelected": true,
"ItemText": "70%"
},
{
"id": 266,
"ID": 266,
"IsSelected": true,
"ItemText": "80%"
},
{
"id": 265,
"ID": 265,
"IsSelected": true,
"ItemText": "90%"
},
{
"id": 264,
"ID": 264,
"IsSelected": true,
"ItemText": "100%"
}
]
}
(id 和 ID 值是故意存在的。我尝试与 {{each}} 块内的字符串连接的任何键都会出现此错误)
【问题讨论】:
标签: jquery internet-explorer-8 jquery-templates