Backbone.js 仅在 IE7 中导致错误 [英] Backbone.js cause bug only in IE7

查看:15
本文介绍了Backbone.js 仅在 IE7 中导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用后端的 CodeIgniter 和前端的 Backbone.js 开发 Web 应用程序.我也使用 HTML5 Boilerplate 作为我的开始模板.

I'm developping a web app with CodeIgniter on back-end and Backbone.js on front-end. I'm also using HTML5 Boilerplate as my start template.

我使用 Backbone 的控制器和历史作为我的应用程序的主要导航.我过去做过一次,一切正常.问题是,当我使用 Backbone.History.start() 开始 hashchange 事件捕获并单击链接 example.com/#home 时,url 中的哈希更改,事件被触发但 2 秒后,哈希被清除从 url 和 javascript 错误仅在 ie7 中抛出.

I'm using Backbone's Controller and History as main navigation through my application. I've done it one time in the past and everything have work fine. The problem is, when i start hashchange event capture with Backbone.History.start() and click on a link example.com/#home, the hash change in the url, the event is fired but 2 seconds after, the hash is cleared from url and an javascript error is throw only in ie7.

我查看了源代码,在 IE7 中通过创建一个 IFRAME 运行一个间隔来检查哈希值变化来实现 hashchange 事件.

I've take a look at source code and hashchange event is acheived in IE7 by creating an IFRAME running an interval to check hash value change.

有人遇到过这个奇怪的错误并且知道如何解决这个问题吗?

Anyone had this weird bug before and know how to solve this?

推荐答案

使用 Backbone 处理 #hash 基础应用程序的正确方法似乎是在 Backbone.history.saveLocation( hash ) 和 Backbone.history.loadUrl() 之后启用控制器的路由.

The right way to handle an #hash base application with Backbone seems to Backbone.history.saveLocation( hash ) and after Backbone.history.loadUrl() to enable Controller's routing.

希望我以前知道这个...享受这个很棒的 MVC 库的乐趣:)

Whish i knew this before... Have fun with this awesome MVC library :)

这篇关于Backbone.js 仅在 IE7 中导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆