mardi 16 janvier 2018

Ember call method defined in mixin

I have the following code in my Ember app;

var FooMixin = Ember.Mixin.create({
  testMethod: function(){
    alert("FooMixin");
  }
});

App.IndexController = Ember.Controller.extend(FooMixin, {
   testMethod: function(){
     alert("IndexController"); // This alerts FooMixin if testMethod not defined in IndexController 
   },
  actions: {
    selectSomething: function(item) {
      this.testMethod();
    }
  }
});

So "testMethod" is defined in the mixin as well as IndexController which extends FooMixin. The action alerts "FooMixin" if testMethod is not defined in IndexController, else it alerts "IndexController"

My question is if this is the normal Javascript inheritance behavior. Anything else that I need to understand on how this thing works with mixin.




Aucun commentaire:

Enregistrer un commentaire