Backbone Router on any page change event

2019-09-16 15:25发布

I have the following routes:

routes: {
    ''                              : 'showSchedulePage',
    'Assignment/:assignmentTitle'   : 'showAssignment',
    ':pageType/:pageName'           : 'showPage'
},

Instead of the same code being fired in each of these functions, how can I fire a function when the URL is ANY one of the ones up top?

Thanks!

1条回答
够拽才男人
2楼-- · 2019-09-16 16:20

Backbone plugin Routefilter allows you to define actions, which should be invoked before and after any route is executed. This allows you to extract common code from route handlers.

查看更多
登录 后发表回答