选择标记默认选择 IE8 在将车把与 Meteor 一起使用时忽略



我创建了一个空白的Meteor项目,并试图在车把HTML文件中放置一个

<head><title>test</title>
</head>
<body>
  <select>
    <option>abc</option>
    <option selected="selected">def</option>
    <option>ghi</option>
  </select>
</body>

因此,IE8 显示"abc"作为所选选项。

我也尝试编写一个 Handlebar 辅助函数,结果相同:

<head><title>test</title>
</head>
<body>
  {{{hbarselect}}}
</body>
// in the js file
Handlebars.registerHelper("hbarselect", function(value) {
    var ret = '';
    ret = '<select>';
    ret += '<option>abc</option>';
    ret += '<option selected="selected">def</option>';
    ret += '<option>ghi</option>';
    ret += '</select>';
    return new Handlebars.SafeString(ret);;
  });

如果我完全忽略Handlebars,只写一个简单的HTML文件,那么IE8的行为正常:

<html>
<head>
</head>
<body>
<select>
<option>abc</option>
<option selected="selected">def</option>
<option>ghi</option>
</select>
</body>
</html>

我需要了解一些关于车把的知识才能完成这项工作吗? 我该如何解决这个问题?

也许这种丢失选定状态的解决方法可能会有所帮助?

https://stackoverflow.com/a/13013326/1758461

最新更新