PDA

View Full Version : List Items disappears in MVC pattern



babar.sajjad
31 Jul 2011, 5:58 AM
Hi

Sencha Touch 1.0.1

I had a list with names and items in it like this

Breakfast
item1
item2
Lunch
item5
.........

when the store loaded it shows me the correct list and when i moves back to page by clicking back button i see this

Breakfast
Lunch
.....
the items i am getting disappears :(

This happens on devices (iPad, iPhone) unable to check this on Andriod.

babar.sajjad
31 Jul 2011, 6:02 AM
This is my List



Application.views.MealList = Ext.extend(Ext.List, {
scroll: false,
itemTpl: [
'<tpl for=".">',
'<tpl if="calories != &quot;&quot; && calories != 0">',
'<div class="fltR"><div class="next">Calories: {calories}</div></div>',
'</tpl>',
'<div class="item">',
'<div class="title">{title}</div>',
'<tpl if="meal_item_count==0">',
'<div class="name">No Items on Plate</div>',
'</tpl>',
'<tpl for="mealitems">',
'<div class="name">{name}</div>',
'</tpl>',
'</div>',
'<div class="clr"></div>',
'</tpl>'
],
store: 'MealStore',
listeners:{
itemtap: function (view, index, item, e){
var rec = view.store.getAt(index);
var itemsInMeal = rec.data.meal_item_count;
var mealuuid = rec.data.uuid;
var mealid = rec.data.id;
var mealname = rec.data.title;
storageObj.setItem('meal_id',mealid);
storageObj.setItem('meal_uuid',mealuuid);
storageObj.setItem('meal_name',mealname);
if(itemsInMeal > 0){
storageObj.setItem('from_url','nutrition/meal_details');
var url = 'nutrition/meal_details';
Ext.redirect(url);
}else{
storageObj.setItem('from_url','nutrition/plan');
var url = 'nutrition/build';
Ext.redirect(url);
}
}
}
});
Ext.reg('mealList', Application.views.MealList);

babar.sajjad
3 Aug 2011, 4:30 AM
Seems that my store structure get changed :(