Is there any better way for handling this instead of dirty workaround using ApplicationRoute._actions
You can use reopen
.
Add this initializer to your ember-cli addon project:
app/initializers/add-action-to-application-route.js
import Ember from 'ember';
export default {
name: 'add-action-to-application-route',
initialize: function(container, app){
Ember.run.next(function(){
var applicationRoute = container.lookup('route:application');
if (applicationRoute && typeof applicationRoute.reopen === 'function'){
applicationRoute.reopen({
actions: {
doMore: function(){
//doing More
}
}
});
}
});
}
};
Existing actions won’t be overridden.
1 Like
Holly smokes! This indeed did the trick.
Thank you so much @ramybenaroya
Is there any particular reason you need to Ember.run.next()
Without the run.next The lookup method returned undefined.