How can I bubble up an Ember action inside a callback function?

丶灬走出姿态 提交于 2019-12-03 16:40:11

you can manually trigger the bubble by calling self.target.send('myAction');

an IndexController defined like this

App.IndexController = Ember.Controller.extend({
  actions: {
    bubbleMe: function(item){
      var self = this;
      alert('IndexController says you clicked on: ' + item);
      setTimeout(function(){
        self.target.send('bubbleMe',[item]);
      }, 1000);
    }
  }
});

would bubble to an ApplicationRoute defined like this

App.ApplicationRoute = Ember.Route.extend({
  actions: {
    bubbleMe: function(item){
      alert('ApplicationRoute says you clicked on: ' + item);
    }
  }
});

You can see a working fiddle here: http://jsfiddle.net/tikotzky/2ce9s32f/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!