Joe Gillon
Joe Gillon

Reputation: 97

Meteor Router.go not passing params

Snippet of code client-side:

Template.projectEditButton.events({
  "click .edit": function() {
    Router.go('projectForm', {prjId: this._id});
  }
});

At this point, this._id is correct. In router file:

Router.route('/projects/form', {
  name: 'projectForm',
  data: function() {
    return Projects.findOne(this.params.prjId);
  }
});

this.params is empty. What am I missing?

Upvotes: 0

Views: 192

Answers (1)

David Weldon
David Weldon

Reputation: 64342

You need to add the parameter to your route definition in order for the mapping to work:

Router.route('/projects/form/:prjId', {
  name: 'projectForm',
  data: function() {
    return Projects.findOne(this.params.prjId);
  }
});

Upvotes: 4

Related Questions