Working in a Sencha touch application I am having a problem with the load of items inside of a tabpanel dynamically..
Code in the view:
{
xtype : 'tabpanel',
layout : 'card',
itemId : 'containerButtons',
items : []
}
Code in the controller :
chooseBrands : function(store){
var item = {};
for(var i = 0; i <store.get('brands').length; i++){
var record = store.get('brands')[i].text;
var items = [item];
console.log(i + ' ' + record);
item = {
title: record
};
items.push(item);
}
this.getSurveyBrands().setItems(items);
},
But it is not working correctly, I am having same record repeated so many times like is the length of the array in the tabpanel ..
Also, I am calling this method while the view is loaded and its refs is with the event initialize
What am I doing wrong??
Thank you in advance.
I found the solution:
chooseBrands : function(store){
this.getSurveyBrands().removeAll();
var item = {};
for(var i = 0; i <store.get('brands').length; i++){
var record = store.get('brands')[i].text;
var items = [item];
item = {
title: record
};
this.getSurveyBrands().add(item);
}
},