mercredi 23 septembre 2015

Calling controller action from Ember 2.0 component

Now that Ember 2.0 decided to remove the Ember.View completely I am having issues of passing actions from the view to the controller.

App.SomeView = Ember.Component.extend({
   didInsertElement : function(){
     var _this = this;
     window.addEventListener("message",
        function(event) {
            _this.get("controller").send("foobar", event.data);
        }, false);
  }
});

App.SomeController = Ember.Controller.extend({
   actions: {
      foobar: function(param) {
         console.log("Yey", param);
      }
   }
});

Because instead of Ember.View I need to use now Ember.Component. And of course then this.get("controller").send method does not work anymore. Is there some kind of workaround for this?




Aucun commentaire:

Enregistrer un commentaire