samedi 7 mai 2016

Ember.js (v2.4.5) component isn't passing up second action

I've got a very simple component which has two actions, start and stop. These are fired when clicking buttons. The first action is bubbled up to the route and works as expected, however the second action is fired in the component, but never makes it to the route.

I have just started playing around with Ember, but I assume components can preform more than one action?

There are no errors in the console, the button just doesn't do anything and the console log from the route is never displayed.

Component actions

actions: {

  start() {
    console.log('component start called');
    this.sendAction('start', this.get('item'));
  },

  stop() {
    console.log('component stop called');
    this.sendAction('stop', this.get('item'));
  }
}

Route actions

actions: {
    start (server) {
        console.log('route start called');
        server.set("settings.amazonTask", 'start');
        server.save();
    },

    stop (server) {
        console.log('route stop called');
        server.set('settings.amazonTask', 'stop');
        server.save();
    }
}

Template

<button type="button"
        class="btn btn-default btn-sm" >
    Turn on
</button>


<button type="button"
        class="btn btn-default btn-sm" >
    Turn off
</button>




Aucun commentaire:

Enregistrer un commentaire