javascript - 使用下划线模板填充 html 时,IE7 和 8 悬停状态不起作用

标签 javascript jquery internet-explorer backbone.js underscore.js

有没有其他人遇到过使用下划线模板引擎时 IE 悬停状态不起作用的问题。 IE7 和 8 不显示悬停状态。如果我删除 _.template() 方法并直接将 html 放入而不是动态地放入,则一切正常。

这是我的下划线模板设置 我还使用 backbone 来存储我的数据,这些数据将使用 this.model.toJSON() 更新模板

var template= _.template( $("#mytemplate").html() );
this.el.html( this.template( this.model.toJSON() ) );

更新: 我把它去掉了,我注意到即使我不使用下划线而只使用 jquery html() 方法它也不起作用。例如:

this.el.html( $("#mytemplate").html() );

这是我的模板代码。

<script id="mytemplate" type="text/template">
    <div class="content">
    <a href="http://www.cnn.com">Testing Rollover</a>
    </div>
</script>

有没有人遇到过这个问题。

最佳答案

ie8 不能很好地处理下划线;这应该修复ie8 var template= ((.template( $("#mytemplate").html() ) ));

您可以在这里引用:https://gist.github.com/39ac06be6abc96c8a69e

关于javascript - 使用下划线模板填充 html 时,IE7 和 8 悬停状态不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8495315/

相关文章:

javascript - Jquery,隐藏img onload

javascript - Nodejs mysql 异步/等待函数

jquery - 如何使选定的标题及其内容处于事件状态,而其他的则处于非事件状态?

html - Youtube HTML5 iframe 嵌入在 IE 中播放

Javascript拆分数组

javascript - 使用 jquery 创建基于 JSON 的动态 SelectBox

jquery - 最好的 jQuery 深度链接/历史插件是什么?

jquery - 为 body 标签覆盖 scaffolding.less

css - 在 IE11 企业模式或兼容模式下清除字段 'x'

javascript - excel onclick 表格