Reputation: 4534
Little and strange issue. I have an array of objects. Here is my controller.
AmbiantBox.AmbiantsController = Ember.ArrayController.extend({
myArray: [],
fillData: function(){
//loop
this.myArray.push({index: 0, status: 'hide'})
//loopEnd
},
updateState: function(idx){
arr=this.get('myArray');
for(i=0;i<arr.length;++i){
obj=arr[i]
if(obj.index==idx){
console.log(idx);
obj.set('status','show');
console.log('===========');
}}}
});
I call this updateStats function from viewSide. It works fine till the line where i console the parameter idx but code seems to break where i set the object. There are no errors in console as well.
Strange. Any help would be appreciated.
Upvotes: 0
Views: 980
Reputation: 4974
If you want to use Ember's set
and get
's it's probably a good idea to use Ember.Object
and Ember.Array
as well.
Try this:
AmbiantBox.AmbiantsController = Ember.ArrayController.extend({
myArray: Em.A(),
fillData: function(){
obj = Ember.Object.create({index: 0, status: 'hide'});
this.myArray.pushObject(obj);
},
});
Upvotes: 1