PDA

View Full Version : Ext.dispatch if a user clicks a link



PHANTOMIAS
4 Nov 2011, 8:08 AM
Hello!


I have a MVC application built with the latest stable Sencha Touch version 1.1.1.
I use a dataview and a template, like this:



tpl: new Ext.XTemplate( '<tpl for=".">',
'<div class=\'highlight\'></tpl>',
'<div class="thumbnail">',
'<img src="{url}.png" />',
'</div>',
'<h1 class="title">{label}</h1>',
'</div>',
'</tpl>'
)


Now, the "highlight" div with the image and the h1 should be tapable/clickable.
What I need is the execution of these lines of code after a user tapped on it:



Ext.dispatch({ controller: myproject.controller.test,
action: 'index',
historyUrl: 'Start/index',
animation: {type:'slide', direction:'left'},
});


How can I do this?


Best Regards Tim

mitchellsimoens
4 Nov 2011, 11:49 AM
You should listen for the itemtap event and do the Ext.dispatch

PHANTOMIAS
7 Nov 2011, 2:27 AM
Thank you for the reply.
Unfortunately, it does not work inside the type dataview.
I did not see the console.log message, so the function is not called.

listeners: {
itemtap: function(dataView, index, item, e) {
console.log(index);
}
}

I also do not understand the index. If I have a list, the index is the number of the tapped list entry. In my data view with XTemplate, I have a for loop. So every loop is assigned to a index?

PHANTOMIAS
7 Nov 2011, 2:33 AM
Ah, I solved it, my itemselector was wrong...