2

I've got a very simple routes. When I click my < a href="#content_ft"> for the first time, the route function matched(ft) will be called. But here comes the question, I click the < a href="#content_ft"> for the second time, the route function(ft) cannot be called.

I think it is because the url in the browser is still *"www.mysite.com/index.html#content_ft"*, backbone think I do not visit a new anchor, so the routes won't work. But what I need is the effect like refreshing the page.I need the route function ft can be called when I click the < a href="#content_ft"> even if the url does not change.

Any help is appreciated!

Here is my Router:

    app.HomeRouter = Backbone.Router.extend({       

    routes : {          
        "content_ft" : "ft",
        "content_view_diag" : "view_diag",
    },

    ft : function() {           
             //do something()       
    },

    view_diag : function(){
            //do something
    },      

});

    app.router = new app.HomeRouter();
    Backbone.history.start(); 
Jason Xu
  • 845
  • 8
  • 22
  • 5
    check this http://stackoverflow.com/questions/8901574/how-to-refresh-a-page-in-a-backbone-application – Sushanth -- Jul 29 '13 at 07:25
  • Hmm, IMHO you need `app.HomeRouter = new Backbone.Router.extend({` and also, do you call afrter creating router `Backbone.history.start();` – Sergey Jul 29 '13 at 09:06
  • I have instance my app.HomeRouter, I just did not write it in my question. Now I hava supplement it. You may not understand my question well.@Sergey – Jason Xu Jul 30 '13 at 02:16

1 Answers1

0

Can you try setting a listened on the anchor to trigger the following and see what happens?

app.navigate("content_ft", {trigger: true});
Xerri
  • 4,916
  • 6
  • 45
  • 54