0

http://jsfiddle.net/pauldechov/u4naE/

App.Router = Em.Router.extend({
enableLogging: true,

root: Em.Route.extend({

    index: Em.Route.extend({
        route: '/',
        connectOutlets: function(router) {
            router.get('applicationController').connectOutlet('application');
        }
    }),

    // why does this work?
    goHome: Em.Route.transitionTo('home'),

    // ...but not this? Am I missing something?
    goHome2: function(router, context) {
        router.transitionTo('home', context);
    },
    home: Em.Route.extend({
        route: 'home'
    })
})
});

我收到一条错误消息:“您必须为事件 'goHome2' 指定目标状态,以便在当前状态 'root.index' 中链接到它。”

例如,如何在此处定义处理程序,以便可以返回 false 并停止传播?我真的应该在视图中执行此操作吗?该怎么做?

谢谢你。

4

1 回答 1

1

好的,我想我找到了。当使用 href="true" 时,你必须指定你的函数 goHome2 是一个 eventTransition。见http://jsfiddle.net/Sly7/u4naE/2/

于 2012-08-04T00:09:48.290 回答