Search code examples
ember.jsember-old-router

Can emberjs router states handle events that child cannot handle?


Like a typical Hierarchical state machine, I want to get events that a child state cannot handle but a parent state can, to be handled in parent state. I get the error "could not respond to event xyz in state Y"

    App.Router = Ember.Router.extend 
      location: "hash"
      enableLogging: true
      x: Ember.Route.extend
        xyz : (router, event) ->
          # Some handling code
        y : Ember.Route.extend()

In the above code is there some way of xyz happens in y state, it can be handled by x ? I assumed that HSM would do that. But its not working


Solution

  • The answer is Yes, the router is a hierarchical state machine and events will be passed the current state and then up to it's parents until it is handled. An error is raised if the event is not handled by any state in the current path.

    If this is not working for you, there is an error in your code somewhere.