简体   繁体   中英

In Ember pre4's router, how do you trigger a route event from within another route?

I have code such as that shown below, and I'm just wondering how I can trigger another event within the route's events. Thoughts?

App.MyRoute = Ember.Route.extend({

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

});

You can just call events.eventOne() using this as the context:

App.IndexRoute = Ember.Route.extend({
    events: {
        eventOne: function() {
            console.log('You got me!');
        },
        eventTwo: function() {
            this.events.eventOne();
        },
    } 
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM