cstrat
cstrat

Reputation: 1047

iron:router - how to override what value is used for _id with {{pathFor}}

I will try explain this the best way I can.

In the application I am building, there are three main views:

I have two collections:

My question: On the third view (game view), I want to have a link which will go back to the competition view. I know that I could just use the back/history to load the URL. After trying to do it and failing a couple times, I want to work out how to do this.

I have this code:

<a href="{{pathFor 'competition'}}">&larr; Back</a>

However it feeds the _id from the Game collection, rather than the Competition collection... not sure how I would even override that. I need it to use Games.competition rather than Games._id


As per Mário's answer, I was able to use a helper like so:

<a href="{{pathFor 'competition' _id=competition}}">&larr;</a>

This works exactly as expected.

Upvotes: 0

Views: 55

Answers (1)

M&#225;rio
M&#225;rio

Reputation: 1612

The solution is simple, iron:router provides: {{pathFor 'competition' _id=someHelperValue}}

Upvotes: 1

Related Questions