2013-11-01 3 views
5

ApplicationRoute의 동작이 goBack 인 경우 (다른 모바일 브라우저의 버그로 인해 goBack을 직접 처리해야합니다.) :Ember.js : 중첩 된 경로에서 ApplicationRoute의 동작 호출

Mobile.ApplicationRoute = Em.Route.extend 
    actions: 
     goBack: -> 
      # TODO: Remove when iOS 7 fixed their history 
      # If there's no route to go back, go to front 
      # TODO: Remove when Microsoft fixed their 
      # back button in offline mode 
      if not (Nn.MobileHelper.isiPhone() or Nn.MobileHelper.isIeMobile()) and @get("router.recentRoute")? 
       return window.history.back() 

      @get("controller").set("isHitBackButton", true) 

      @transitionTo("front").then => @get("controller").set("isHitBackButton", false) 

이 동작을 다른 경로에서 어떻게 트리거 할 수 있습니까? @transitionTo을 호출해야하므로이 코드는 반드시 경로 안에 있어야합니다.

답변

5

기본적으로 응용 프로그램 경로에 버블 업 동작이 발생합니다! 템플릿에 {{action 'goBack'}}을 사용하거나 코드 (마이너스 구성 요소)에서 this.send('goBack')으로 전화하면됩니다. 구성 요소에서 약간 다른 이벤트 호출을 연결하고 this.sendAction('internalActionName')을 사용해야합니다.

http://emberjs.jsbin.com/ulIhUze/1/edit

관련 문제