Setup
Imagine an Ember.js app (tried v1.13.9) with this structure:
- ApplicationRoute
- IndexRoute
- IndexController
On the index template, there's simply a button with an action:
<!-- index/template.js -->
<button {{action 'ping' 'index template'}}>index</button>
All routes/controllers handle this action, printing out a message and passing the action up until it reaches ApplicationRoute
. Eg, for IndexRoute
it is:
// excerpt from index/route.js
actions: {
ping(from) {
console.log('IndexRoute^ping from', from);
return true;
}
}
This same action can also originate at IndexController
:
// excerpt from index/controller.js
thingsHappen() {
this.send('ping', 'index controller');
}
You can see the code and play with it at these URLs:
- See the Github gist: http://ift.tt/1MW18NK
- Play with the twiddle: http://ift.tt/1fPrUKK
Question
When you press the button, the messages show that the action is seen by all three routes/controllers, in order, from the inside bubbling up. However, when the action is sent from IndexController
, it skips IndexRoute
. Why is this?
Aucun commentaire:
Enregistrer un commentaire