lundi 6 avril 2015

active path on nested resource active

if I have:



this.resource('companies', function() {
this.resource('company', {path:':company_id'}, function() {
this.resource('employees');
});
});


and have two link-to routes specified for the company and employees on each of the listed companies. (one is to edit the company, and the other to display the company employees).



{{#each}}
{{#link-to 'employees' id}}{{name}}{{/link-to}}
{{#link-to 'company' this}}edit{{/link-to}}
{{/each}}


both links become "active" when I visit the employees.


this is because the uri sub-path for the employees is the same as the company.


the outlet for both the company and employees route view are both individually rendered under the companies. (however, I'm only overriding the renderTemplate method on the employees route to render into the companies outlet)


so the problem is that both links are active.


I do not want the "edit" company to be active when I am simply viewing the company employees.


I tried to "reset" the path somehow and that didn't work, so my solution currently is to put employees route under the companies route, not under company and then passing id to link-to for each item, then catching it in the model hook params when rendering the employees route. but this doesn't let me then use the "modelFor" for parent resources. this solution is okay and works for me currently, but I feel there has to be a way around this.


any thoughts appreciated, thanks.





Aucun commentaire:

Enregistrer un commentaire