2015-08-08 63 views
1

我有一個導航欄項目鏈接到一個孩子的路線,但有活動類的父路由

{{#link-to 'customer'}} 

當點擊我希望它路由customer.details路線。我目前可以通過將customer路由重定向到customer.details來實現此目的。但是,如果在customer.details路線中,如果我點擊導航中的鏈接,它將轉換爲customer路線,而不是將其發送到customer.details。沒有路線功能,如redirect,activate或模型之前/之後,在轉換到路線鏈時觸發。

{{#link-to 'customer.details'}} 

另一種選擇將意味着任何其他customer.routename不會繼承活動類。

我錯過了什麼嗎?謝謝。

回答

1

所以一個修訂者KerrickLong幫我出這一點:


嘗試具有重定向到customer.details住customer.index路線上,而不是直接的顧客路線上。

完美的作品!

+0

關於如何做到這一點的一些示例代碼將不勝感激:) – pusle

1

我的鏈接在Ember 2.0上使用Goobi的上述解決方案進行。

在我的路由器,我有:

this.route('event', {path: '/:eventShortName'}, function(){ 
    this.route('index', {path: '/'}); 
    this.route('new-article', {path: 'new-article'}); 
    this.route('page', {path: ':articleTitle'}, function(){ 
     this.route('data', {path: ':dataId'}); 
    }); 
    }); 

每當我走訪了event.page.data,在導航欄的所有鏈接將被激活。

修復前:

{{#link-to 'event.page' article.articleURL class="nav-dynamic hidden-xs" tagName="li" href=false}} 
    {{#link-to 'event.page' article.articleURL }} 
     {{article.articleTitle}} 
    {{/link-to}} 
{{/link-to}} 

修復程序後:

{{#link-to 'event.page.index' article.articleURL class="nav-dynamic hidden-xs" tagName="li" href=false}} 
    {{#link-to 'event.page.index' article.articleURL }} 
     {{article.articleTitle}} 
    {{/link-to}} 
{{/link-to}} 

的功能保持不變,訪問數據的URL沒有鏈接是活動的,現在時。

相關問題