我创建了一个基于Backbone,ICanHaz和jQuery的Web应用程序。
可在此处找到:http://development.zeta-two.com/development/f14
它在Chrome(12.0.742.122)中运行良好,但在FF5(5.0.1)和IE9(9.0.8112.16421)中断。
在FF中我没有任何错误,只有一些关于qTip中的CSS的警告(一个jquery plguin)。 似乎它在PlayerView.js的第18行失败,看起来像这样。
$(this.el).html(ich.player(rendermodel.toJSON()));
我已经验证“this.el”是HTML元素,“ich.player(rendermodel.toJSON())”包含要插入的html。我甚至试过像
这样的东西$(this.el).html('Test');
但即使这样也行不通。
在IE9中它打破了ItemDetailsView.js的第12行,看起来像这样。
data = this.model.toJSON();
错误是:对象不支持属性或方法toJSON。 请注意,我已包含json2.js
这两个错误的原因是什么?
答案 0 :(得分:1)
firefox错误是由PlayersAppView.js第18行引起的,它引用了this.players(这是窗口对象)。在chrome中,这显然是对#players的引用,但在FF中它不是。通过将下划线的_.each的上下文更改为 this (即视图)来修复该错误。
IE错误是由PlayersAppRouter.js的第25行引起的,其中变量“item”未使用关键字“var”声明,之后IE将其与函数“item”混合。