Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember link-to Set Active Class Immediately

I have a nav bar that has special CSS that shows up when a link has the "active" class on it. It looks something like this:

<ul>
    <li>{{link-to "routeName"}}<i class="icon-up"></i>{{/link-to}}</li>
    {{!-- more list items like the previous one... --}}
</ul>

However, when I click on the link with "routeName", a rather expensive query is made that may be slow at times. I have a LoadingRoute set up with a loading view that consists of a simple spinner, but it seems like the link does not receive the "active" class until the route's promise is resolved. Is there a Handlebars-friendly way to tell link-to to immediately set the "active" class when it is clicked?

like image 776
Vinay Avatar asked Mar 20 '26 03:03

Vinay


1 Answers

The reason for this is that the URL does not get updated until the end of a transition. Thanks to the peeps in the Ember IRC and Machty, this is an issue that has been resolved and will be in the next beta cycle.

  • The fix: https://github.com/emberjs/ember.js/pull/4122
  • The beta cycle "go" progress: https://github.com/emberjs/ember.js/issues/4052
like image 189
Vinay Avatar answered Mar 23 '26 21:03

Vinay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!