Emberjs core has a new router implementation which extends Ember.StateManager. This is the basic router I have currently 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: "/"
Emee is my Ember namespace. I have a couple of questions:
1) When a page is loaded with a url with a hash http://localhost:3000/#tasks
it moves to the correct start.tasks.index state, but on hashChange it just sends a message to the routePath of the current state.
Emee.stateManager.route("/tasks") also does the same thing. It does not change the state and sends a message to routePath of the current state. Do we need to implement routePath ourselves? If not how do we change state by providing a route?
2)I see a lot of changes to which function will be called upon entering state. As of now "connectOutlets" seems to be the name of the function being called on entering state. Is this now the correct page to setup controllers?
UPDATE
Updated ember code to the latest revision. My router now looks like this:
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()
The browser forward and back buttons still don't work. They call routePath
which just returns because they are all leaf nodes. I think I am missing something small but have not been able to put my finger on it.