How to refresh a page in a backbone application

后端 未结 13 2385
北恋
北恋 2021-01-30 22:32

I am using backbone to build my web app.

Currently I am facing an issue whereby if I am on the home page, I am unable to refresh the same page by just clicking on the \'

13条回答
  •  别跟我提以往
    2021-01-30 23:00

    You're looking for Backbone.history.loadUrl. From the Annotated Source:

    Attempt to load the current URL fragment. If a route succeeds with a match, returns true. If no defined routes matches the fragment, returns false.

    So, for a simple refresh link, you can add the following event to your Backbone.View:

    events: {
      'click a#refresh': function() {
        Backbone.history.loadUrl();
        return false;
      }
    }
    

提交回复
热议问题