Ember effect sent from index controller not being processed by pointing route

https://emberjs.jsbin.com/depoxiseve/edit?js,output

When observing the model change on the controller, sending the pointer from the index controller is not handled by the pointing route. It invokes an action not handled by an error. It will be processed in the application route. Why is this? Is it because the index route hasn't been activated yet? Is there a way to make this work?

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return ['red', 'yellow', 'blue'];
  },
  actions: {
    test: function() {
      console.log('test');
    }
  }
});

App.IndexController = Ember.Controller.extend({
  test: function() {
    this.send('test');
  }.observes('model')
});

      

+3


source to share


1 answer


Well JSBin seems to be broken at the moment, but I think if you want an action to bubble, you need to create an action test

on your controller and then return true

from an action. Because this.send('test');

will dispatch a test action to this

what is actually a controller.

So:



App.IndexRoute = Ember.Route.extend({
 model: function() {
    return ['red', 'yellow', 'blue'];
  },
  actions: {
    test: function() {
      console.log('test');
    }
  }
});

App.IndexController = Ember.Controller.extend({
  test: function() {
    this.send('test');
  }.observes('model'),
  actions: {
    test: function() {
      return true;
    }
  }
});

      

PS What are you trying to do? It is generally a good idea to avoid observers if currently possible (performance issues, apparently).

0


source







All Articles