Combine linkTo and action helpers in Ember.js

后端 未结 8 1976
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 13:50

I need to combine linkTo and action helpers in Ember.js. My code is:

{{#link-to \'index\'}}Clear{{/link-to}}
         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 14:40

    I like Cereal Killer's approach for its simplicity, but unfortunately it exhibits a problem for me. When the browser navigates to another route, it restarts the Ember application.

    As of Ember 2.6, the following simple approach does the trick:

    {{#link-to 'home' preventDefault=false}} Go Home {{/link-to}}

    This achieves the following:

    • navigates to route 'home'
    • action 'closeNavigationMenu' is invoked
    • on mouseover, browser displays link that will be followed (for SEO and better UX)
    • browser navigation does not result in reboot of Ember app

提交回复
热议问题