vendredi 10 juillet 2015

Ember {{link-to}} helper not adding active class automatically for dynamic segment routes on rerender

For dynamic routes in Ember used in {{link-to}} helper, when the current route matches the href of the {{link-to}}, Ember automagically adds the "active" class to the tag. However, when you go directly to the dynamic segment route instead of navigating to it, Ember doesn't add the "active" class to the tag. I want Ember to add the "active" class whether the user navigates to the segment from root or directly.

For example, the user is on #/photos and clicks on "Puppy Running", the route would change to #/photos/2 and Ember would add class="active".

<ul>
  <li><a href="/photos/1">Happy Kittens</a></li>
  <li><a href="/photos/2" class="active">Puppy Running</a></li>
  <li><a href="/photos/3">Mountain Landscape</a></li>
</ul

However, when the user goes directly to #/photos/2 from their browser, you would expect that class="active" would be added to Puppy Running tag, but it fails to do so.

The documentation is here: http://ift.tt/1SdSutN and it seems to imply that it would add the active class automatically if routes matched, but it doesn't seem to work that way.

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire