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是我的Ember命名空间 我有几个问题要问:
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( 2) 我可以看到许多改变, 哪个函数会被调用到进入状态。 从现在起, “ 连接输出” 似乎是调用进入状态的函数的名称 。 现在这个页面是否是设置控制器的正确页面?
UPDATE
更新了最新版本的混合代码。 我的路由器现在看起来像这个:
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()
前向和后向浏览器按钮仍然不起作用。 它们称为 < code> routePath code>, 它们只是返回, 因为它们都是叶节点。 我认为我漏掉了一些小东西, 但无法将手指放在它上 。