2014-01-06 21 views
1

我試圖在ApplicationRoute錯誤操作中執行this.transitionTo('route name')當在Ember中遇到錯誤時轉換

似乎發生的事情是,當我點擊鏈接時,它遇到了錯誤,並且沒有轉換到目標路線,似乎是說它正在轉換到它剛剛在其中的路線。這是使用{{#link-to}},所以我有一種感覺,有一些神奇的在那裏...

我想使用this example

錯誤發生在路由上的model()方法(使用jquery並返回一個promise [jqXHR]),因爲我返回了一個401的http代碼。

這是不正確的?

App.ApplicationRoute = Ember.Route.extend(
    actions: 
     error: (error, transition) -> 
      if error.status == 401 
       @transitionTo('login') 
) 

我試着在設置.ajaxError方法,並在那裏過渡,但結果似乎沒有任何變化的另一件事。

App.ApplicationRoute = Ember.Route.extend(
    setupController: (controller, model) -> 
     route = @ 
     Ember.$(document).ajaxError((event, jqXHR, ajaxSettings, error) -> 
      if jqXHR.status == 401 
       route.transitionTo('login') 
     ) 

     controller.set('content', model) 
) 

有沒有人得到這個工作上的燼1.2.0?

回答

0

原來這是在我結束的問題。我有一些額外的邏輯,基本上是對抗我的轉變!哎呦!