PDA

View Full Version : itemTap index remembers previous value



cpsp
18 Mar 2011, 2:03 PM
I am trying to build a clickable (touchable actually) list that calls a different page for each of the items tapped.
I used the itemTap listener and then evaluate index to see where the user tapped (simple if statement in the code below). This works well on the first tap, but on subsequent taps the function returns the index of the previous tap.
I would appreciate any help you can give me to figure this out.

Thanks!!!


Ext.regModel('model1', {
fields: ['list1']
});

demos.ListStore = new Ext.data.Store({
model: 'model1',
sorters: 'list1',
getGroupString : function(record) {
return record.get('list1')[0];
},
data: [
{list1: 'thing 1'},
{list1: 'thing 2'},
{list1: 'thing 3'},
{list1: 'thing 4'},
{list1: 'thing 5'}
]
});


demos.List = new Ext.Panel ({

items: [{
width: Ext.Element.getViewportWidth(),
height: Ext.Element.getViewportHeight()-40,
temSelector: 'strategy',
xtype: 'list',
store: demos.ListStore,
itemTpl: '<div class="contact"><strong>{list1}</strong></div>',
listeners: {
"itemtap": function(list, index, item, event) {
if (index===0){var testtapped='tapped 0'}
else {var testtapped='nottapped 0'}
if (!this.popup) {
this.popup = new Ext.Panel({
floating: true,
modal: true,
centered: true,
width: 300,
height: 400,
styleHtmlContent: true,
scroll: 'vertical',
html: '<h1>'+testtapped+', tapped:'+index+'</h1>,
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
title: 'Overlay Title'
}]
});
}
this.popup.show('pop');
}
}
}]
});