I'm having a headache with Backbone router in Safari
I have this piece of code:
app.navigate("ask/" + encodedSearchKey,true);
and in my router:
var AppRouter = Backbone.Router.extend({
routes:{
"":"main",
"ask/*encodedSearchKey":"askSearch",
},
askSearch:function(){
...
},
...
});
app = new AppRouter();
Backbone.history.start();
In chrome, it works as expected, the URL gets routed and the askSearch function gets called once
however, in Safari, the askSearch function actually gets executed twice
and when I tried
app.navigate("ask/" + encodedSearchKey,false);
In chrome the askSearch function was not called as expected, but the Safari it actually gets called once
I have run through the debugger and am pretty sure the app.navigate line always gets called once only, and there is nothing else that could fire the askSearch function except the router itself
now I know I can fix this by detecting browser type, but I did not find any similar problems online, it seems that people do not have this issue, am I doing something very wrong here?