Emberjs Router: Status Does Not Change When URL Hash Changes

The Emberjs core has a new router implementation that extends Ember.StateManager. This is the basic router that I have just implemented (using coffeescript):

Emee.set "stateManager", Ember.Router.create
    location: "hash"
    enableLogging: true

    start: Ember.State.extend
        index: Ember.State.extend
            route: "/"
            connectOutlets: (manager) ->
                console.log(manager)

        tasks: Ember.State.extend
            route: "/tasks"

            index: Ember.State.extend
                route: "/"

            show: Ember.State.extend
                route: "/show"

        users: Ember.State.extend
            route: "/users"

            index: Ember.State.extend
                route: "/"

Amy is my Ember namespace. I have a couple of questions:

1) When the page is loaded with a hash URL http://localhost:3000/#tasks, it goes into the correct start.tasks.index state, but in hashChange it just sends a message to routePath of the current state. Emee.stateManager.route ("/ tasks") also does the same. It does not change state and sends a routePath message to the current state. Do we need to implement routePath ourselves? If not, how can we change the state by specifying a route?

2) , . "connectOutlets", -, . ?

UPDATE

ember . :

Emee.Router = Ember.Router.extend
    location: "hash"
    enableLogging: true

    root: Ember.State.extend
        index: Ember.State.extend
            route: "/"
            redirectsTo: 'tasks.index'

        tasks: Ember.State.extend
            route: "/tasks"

            index: Ember.State.extend
                route: "/"
                connectOutlets: (manager) ->
                    console.log("in index");

            show: Ember.State.extend
                route: "/show"
                connectOutlets: (manager) ->
                    console.log("in show");

        users: Ember.State.extend
            route: "/users"

            index: Ember.State.extend
                route: "/"

Emee.initialize()

- . routePath, , . , - , .

+3
2

, :). 0.9.8.1, , https://github.com/emberjs/ember.js/issues/887#issuecomment-5946213. , "" "" Ember.Location.

Ember.Application.reopen({
  setupStateManager: function(stateManager) {
    var location = Ember.get(stateManager, 'location');

    if (typeof location === 'string') {
      location = Ember.Location.create({style: location});
      Ember.set(stateManager, 'location', location);
    }

    stateManager.route(location.getURL());
    location.onUpdateURL(function(url) {
      stateManager.transitionTo('root');
      stateManager.route(url);
    });
  }

});
+2

All Articles