Ember link-to Set Active Class Immediately

自作多情 提交于 2019-12-07 17:04:27

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/21420098/ember-link-to-set-active-class-immediately

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!