PDA

View Full Version : Tap on each item code, help PLEASE



javismiles
23 Jul 2011, 11:24 PM
dear friends, why is this code not working?
im trying to detect the tap on each item of a carousel, to target just each of the items

afterrender: function(c) {
c.items.each(function(item) {
item.el.on('tap', function() {
alert("tapppp");
});
});
}
.......etc

jjerome
25 Jul 2011, 10:12 AM
Try just adding a listener to the Carousel component to handle tap events. It should record which item of the carousel was tapped.

javismiles
25 Jul 2011, 11:06 PM
eh.... well thats kind of what i showed above :))
could you show the code you are talking about?
smiles
:)

jjerome
26 Jul 2011, 4:40 AM
This is what I was talking about. I've just never seen it done the way you are doing it.




//create some carousel component
var carousel = new Ext.Carousel({
id: 'car1',
direction: 'horizontal',
indicator: true,
items: [{
html: 'Some page filler text',
cls: 'card card1'
},
{
html: 'More page filler',
cls: 'card card2'
}],
listeners: {
itemtap: function(dv, idx, itm , e){
//dv = the subclass component tapped on
//idx = the index of the node (like in a list)
//itm = the element tapped on
//e = the event that was performed

//here you could handle what you wanted, i thought
}
}
});

javismiles
27 Jul 2011, 2:15 PM
thank you , but i do that and nothing happens, that event doesnt seem to get detected
im using an alert and nothing happens, see below

listeners: {
itemtap: function(dv, idx, itm , e){
//dv = the subclass component tapped on
//idx = the index of the node (like in a list)
//itm = the element tapped on
//e = the event that was performed
alert (dv+" "+idx+" "+itm+" "+e);

//here you could handle what you wanted, i thought
}
}

bharatn
27 Jul 2011, 2:55 PM
Look at the events api for carousel. Try using cardswitch event.

javismiles
27 Jul 2011, 2:59 PM
I will try that, although its not really the event i was thinking about

by the way do you know how to dynamically change the html text of an item in a carousel?
i cant find a way to address it and see it change
Ext.getCmp('row1-1').setHTML("Changedtext");

bharatn
27 Jul 2011, 3:11 PM
I meant the cardswitch events - look at beforecardswitch too.

Use update() instead of setHTML.