Ember链接 - 立即设置活动类 [英] Ember link-to Set Active Class Immediately

查看:92
本文介绍了Ember链接 - 立即设置活动类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个导航栏,具有特殊的CSS,当链接具有active类时。它看起来像这样:

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>

但是,当我点击链接routeName,一个相当昂贵的查询是有时可能很慢。我有一个 LoadingRoute 设置一个包含一个简单的微调器的加载视图,但似乎链接没有收到活动 / code>类,直到路由的承诺得到解决。有没有Handlebars友好的方式来告诉链接到,以便在点击时立即设置活动类?

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?

推荐答案

这样做的原因是网址在转换结束之前不会更新。感谢Ember IRC和Machty中的窥视,这是一个已经解决的问题,将在下一个测试周期。

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

这篇关于Ember链接 - 立即设置活动类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆