How to refresh a page in a backbone application

后端 未结 13 2158
北恋
北恋 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 22:41

    You can often modify your route to include a splat, so that you can append a random string to the end of an href to make it unique, but still match the "home" route. (Note: make this your last route.)

    In the routes:

    routes: {
        "*str": "home"
    }
    

    In the view:

    render: function() {
        var data = {href: +(new Date())};
        _.extend(data, this.model.attributes);
        this.$el.html(this.template(data));
        return this;
    }
    

    In the template (handlebars shown here):

    Home Link
    

提交回复
热议问题