Skip to content

Instantly share code, notes, and snippets.

@ilovett
Last active December 17, 2015 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilovett/5632929 to your computer and use it in GitHub Desktop.
Save ilovett/5632929 to your computer and use it in GitHub Desktop.
Give multiple arguments to your linkTo function in Ember.js
<ul>
{{#each object in controller}}
<li>{{#linkToContext 'child' object.relatedGrandParent object.relatedParent object }} link {{/linkToContext}}</li>
{{/each}}
</ul>
var linkTo = Ember.Handlebars.helpers.linkTo;
Ember.Handlebars.registerHelper('linkToContext', function() {
linkTo.apply(this, arguments);
});
<ul>
<li><a href="/grandparent/23/parent/35/child/32/index">link</a></li>
<li><a href="/grandparent/565/parent/567/child/554/index">link</a></li>
<li><a href="/grandparent/523/parent/123/child/99/index">link</a></li>
</ul>
App.Router.map(function() {
this.resource('grandParent', { 'path' : '/grandparent/:grand_parent_id' }, function() {
this.resource('parent', { 'path' : '/parent/:parent_id' }, function() {
this.resource('child', { 'path' : '/child/:child_id' });
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment