1

I've encountered a peculiar issue when dealing with Backbone routing.

Our app is being hosted in example.com/photo/index.php, and we'd like to hook an event on it which when triggered, appear in the address bar as example.com/photo/<ID>. Below is how we set up our rewrite rule androuter settings:

RewriteRule ^/photo/([0-9]+)?$ /photo/index.php/photo/$1 [L]

Inside Backbone.Router.extend:

routes: {
    'photo/:ID': 'viewPhoto'
},

After router has been instantiated:

$(function() {
    Backbone.history.start({
        pushState: 'pushState' in window.history,
        root: '/'
    });
});

This works great in Firefox/Chrome/Safari, but in IE9 you have to access the event hook with example.com/photo/#photo/<ID>, which is not very cool.

So we tried toggling the pushState option on (pushState: true) and hope it could help, but now whenever accessing example.com/photo/<ID> in IE9, page will be redirected to example.com/#photo/<ID> instead, and actually displaying the content of example.com/index.php.

I suppose (?) this can be a non-issue if we change the event hooking URL to something like example.com/photo/view/<ID>, however we can't touch that part.

Is there anyway to make either example.com/photo/<ID>, example.com/#photo/<ID>, or example.com/photo/#<ID> working as expected under IE9, with or without pushState?

gsklee
  • 4,774
  • 4
  • 39
  • 55

0 Answers0