How do I create dynamic URL's with Meteor?

醉酒当歌 提交于 2019-12-03 15:12:09

Use backbone's router, see: http://backbonejs.org/#Router-routes
For regexps like your example see: http://blog.rjzaworski.com/2011/12/regex-routing-with-backbone-js/
Try out the todo example on meteor, see the client/todo.js file:

////////// Tracking selected list in URL //////////

var TodosRouter = Backbone.Router.extend({
  routes: {
    "todo_list/:list_id": "main"
  },
  main: function (list_id) {
    Session.set("list_id", list_id);
    Session.set("tag_filter", null);
  },
  setList: function (list_id) {
    this.navigate("todo_list/"+list_id, true);
  }
});

Router = new TodosRouter;

Meteor.startup(function () {
  Backbone.history.start({pushState: true});
});

An alternative to using Backbone's router is Meteor Router. I can't vouch for it, only having just discovered it myself but it looks fairly full-featured.

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