Pergunta

I'm building a Backbone.js app with hash based navigation. It works fine everywhere except IE7. In IE7, when I click on a link that changes the hash, what happens is:

  • the page changes
  • the hash then reverts to the previous value
  • the page changes to the previous page as well

I made the links work by adding saveLocation calls to the controller after loading each page, however when I use the back button or reload the page, it always takes me to the home page instead of going back or reloading the current page.

What can I do to make the back button and page reloading work?

Foi útil?

Solução

I made some changes to backbone to make it work for me. You can have a look at my repo here:

https://github.com/juggy/backbone

Works for me so far. I dunno if I broke anything else. I inspired myself from YUI and https://github.com/cowboy/jquery-hashchange/blob/master/jquery.ba-hashchange.js .

Outras dicas

I also had same IE7 problem with you, and tried every way (saveLocation things, Backbone patches, etc).. but it didn't work out. It seems IE7 misunderstand when switching thru many pages.

My final solution was not to use Backbone.history but jQuery History Plugin.

http://tkyk.github.com/jquery-history-plugin/

I know this is the worst workaround because this solution relies on other plugin, but fortunately, Backbone.Controller just handles routings and state handling that you don't have to use it.

jQuery History Plugin just works.

An answer has been posted in Backbone.js cause bug only in IE7.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top