PDA

View Full Version : Itemtap Listener not working properly for panel



NMFord
13 Jan 2012, 9:15 AM
Hey guys,

I am trying to get the itemtap listener working properly for this panel (it's inside a tab panel) so that when users click the "Abstract" link for each item I can dispatch something to the controller.

The list of items is working fine but I can't seem to get the links to respond to any sort of tapping with the listener I have. (At the moment I'm trying to just popup a browser alert to test if it is working).

EDIT: Okay I just realised there is no itemtap event for panels, that I need to use a dataview for this. The problem is this record is being updated to the panel after clicking an itemdisclosure on a list in a previous view and a store is not being accessed here (the store is being accessed on the previous view and I'm calling the update() function to set the data here). How can I add a tap event? For a demo see here: http://www.finite-element.com/sencha/

Do I have to create a new store, populate the store with the array and then create a list from the store? Seems like a complex way of producing some pretty simple functionality. I feel like there should be a way for me to add an event listener for one of these links being tapped without jumping through hoops.

The references are in a store which is in a has many relationship to the main store which is used to populate the search page. Then on the search page, when the item disclosure button is pressed I use update() to send the data from the record to the panels on the page for viewing each item. Then the references tab on the view page uses an xtemplate (seen below) to loop through the gene_rif array.



this.referencesTab = new Ext.Panel({
title: 'References',
scroll: 'vertical',
tpl: new Ext.XTemplate(
'<tpl for="gene_rif">{rif} [<a href="#" id="{pubmed_id}" class="abClick" onclick="return false;">Abstract</a>]<br/><br/></tpl>'
),
itemSelector:'a.abClick',
listeners:{
'itemtap': function(dataview, index, item, e){
alert("roar");
}
}
});

NMFord
13 Jan 2012, 11:14 AM
Ended up creating a new store just for listing the items out in the view. Seemed a bit redundant since I already had the items in another store and in an array, but oh well.