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
,这段代码必须在路由中。