0

我有如下所示的代码,我只是想知道如何在路由事件中触发另一个事件。想法?

App.MyRoute = Ember.Route.extend({

events: {
  eventOne: function() {
     // do something
  },
  eventTwo: function() {
     // how do I call eventOne() here?
  },
}

});
4

1 回答 1

2

您可以只调用events.eventOne()usingthis作为上下文:

App.IndexRoute = Ember.Route.extend({
    events: {
        eventOne: function() {
            console.log('You got me!');
        },
        eventTwo: function() {
            this.events.eventOne();
        },
    } 
});
于 2013-02-08T16:33:13.420 回答