So I havea list of posts in a forum format, and right now I want to be able to access the posterID property of the store post when clicking on the avatar image of the user. I've attached a select listener to the image, but I'm unsure how to access the parent store of the image. I've tried looking through sencha's documentation and search has failed me.
store: 'topicStore',
itemTpl:
'<div class="post">' +
'<div class="header">' +
'<img id="avatar" src="{avatar}" width=48 height=48>' +
'<h2>{displayName}</h2>' +
'<div class="date">on {postDate:date("m/d/Y")}</div>' +
'</div>' +
'<div class="body">' +
'{message}' +
'</div>' +
'<tpl if="signature">' +
'<hr />' +
'<div class="signature">' +
'{signature}' +
'</div>' +
'</tpl>' +
'</div>',
listeners: {
select: function() { return false;},
tap: {
fn: function(event, el, record){
tempElement = el.src;
if (el.id != 'avatar'){
tempElement = tempElement.replace('_th.jpg', '_mid.jpg');
var logo = Ext.create( 'Ext.Img', {
src: tempElement,
id: 'logo',
mode: 'element'
});
app.fireEvent('forum-onimgview',logo);
}
else if (el.id == 'avatar'){
console.log(record);
}
},
element: 'element',
delegate: 'img'
}
}
Does anyone know how to get the parent store of the selected Item? All the gets returned on the listener is the image and dom elements. Thanks in advance!
Try using itemTap listener, it will give you reference to the list.
I use it like this:
listeners: {
itemtap: function (list, index, element, record)
{
/* Put your logic here*/
}
}
More details can be found here: http://docs.sencha.com/touch/2-1/#!/api/Ext.dataview.DataView-event-itemtap