我已經建立了一些基本的路由在我的應用程序使用的示例內的根函數我有一個從視圖操作如觸發一些事件:Ember.js路由器事件在<a href="http://emberjs.com/guides/outlets/#toc_the-router" rel="nofollow">http://emberjs.com/guides/outlets/#toc_the-router</a></p> <p>不工作
gotoStepOne: Ember.Route.transitionTo('stepOne'),
gotoStepTwo: Ember.Route.transitionTo('stepTwo'),
gotoStepThree: Ember.Route.transitionTo('stepThree'),
gotoStepFour: Ember.Route.transitionTo('stepFour'),
gotoStepFive: Ember.Route.transitionTo('stepFive'),
完整的示例路由器代碼在http://jsfiddle.net/hellosmithy/WdjXT/
這一切都工作正常。問題是我想將其他代碼添加到這些事件中。例如:
gotoStepOne: function() {
if (someCondition) {
Ember.Route.transitionTo('stepOne');
}
someOtherFunction();
}
但是,這樣做會中斷路由而不會引發任何錯誤。它只是不再過渡。
具體而言,我只希望在滿足特定狀態時進行轉換 - 在用戶可以繼續進行之前,已在每個階段選擇或輸入了一些內容。有沒有解決方法,或者我應該在其他地方抽象這個功能?
由於這似乎是一個不錯的方法 – hellosmithy 2012-08-14 12:30:10