Backbone.js and regex routing

不羁的心 提交于 2019-12-06 07:35:05

问题


Is it possible to register a route for /pages/*url but not for /pages/*url/edit/ where URL can be something like this foo/bar/and-so-on?


回答1:


router.route supports using a regex natively.

initialize: function(options) {

  // Matches /117-a/b/c/open, passing "117-a/b/c" to this.open
  this.route(/^(.*?)\/open$/, "open");

},

open: function(id) { ... }


来源:https://stackoverflow.com/questions/10270840/backbone-js-and-regex-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!