有没有其他人遇到过使用下划线模板引擎时 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() ) ));
关于javascript - 使用下划线模板填充 html 时,IE7 和 8 悬停状态不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8495315/