Ryan
Ryan

Reputation: 109

internet explorer in IE 7 Standards mode invokes router in backbone twice on refresh

This is easily reproducible with the below code.

The problem is when a URL with a hash (any hash e.g. http://localhost:8000/error/#whatever) is navigated to then refreshed, Internet Explorer invokes the catch-all route *url category (and alerts) but then proceeds to remove the hash and reinvoke the route a second time.

The page works as intended with Webkit, Firefox, Opera etc with only one alert triggering on a refresh. Testing was done locally. All libraries used are the latest versions.

Note: in IE8 and IE9 the rendering engine will default to IE7 Standards mode due to using an html5 doctype - in IE8 and IE9 standards mode this works as intended.

<html><head>
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery171.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/underscore131.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/backbone091.js"></script>
<script>

App = {
    start: function(){
        new App.CatalogRouter();
    }
}

App.CatalogRouter = Backbone.Router.extend({
    routes: {
        'checkout/' : 'checkout',
        '*url' : 'category'
    },

    category : function(url){
        alert('should only trigger once');
    },

    checkout: function(){

    }
})

$(function(){
    App.start();
    Backbone.history.start();
});
</script>
</head>
<body></body>
</html>

Upvotes: 2

Views: 1081

Answers (1)

brad
brad

Reputation: 75454

This was a bug in Backbonejs and has since been fixed.

Upvotes: 1

Related Questions