mardi 26 mai 2015

Why Array controller with itemcontroller has different 'this' object?

I defined an arraycontroller as:

Kiford.ChatboxesController = Ember.ArrayController.extend({
itemController: 'chatbox',
currentParticipant: undefined,
actions:{
    react: function(){
       console.log(this);
    },
}

and I have a template using this controller:

{{#each item in controller}}
    <div {{action 'react'}}>test react</div>
{{/each}}

when I clicked on the div with 'test react' text, the output of console prints value of this:

enter image description here

But when I send action from another controller as:

this.get('controllers.chatboxes').send('react');

The output value of 'this' is:

enter image description here

Apparently, the two 'this' are completely different objects, Why?

and How I can access the first 'this' object with child controller object when I send action from other controller?




Aucun commentaire:

Enregistrer un commentaire