-
12 Nov 2010 8:09 PM #1
Event delegation in list
Event delegation in list
Hi,
Based on http://www.sencha.com/blog/2010/11/1...-sencha-touch/ i have tried to implement in a list
If i use itemtap i could get details likeCode:var list = new Ext.List({ tpl: '<tpl for="."><li><img src="{avatar}" /><h1>{name}</h1></li></tpl>', listeners: { el: { tap: function(){ }, delegate: 'img' } } });
How could i get these value when i used event delegation technique in a list.Code:“itemtap”: function(list, index, item, e)
I just only want to make a particular tag selectable.
-
15 Nov 2010 2:35 AM #2
Hi could anyone tried event delegation in list,.
I used this to make it work anyway
Code:listeners:{ itemtap:function(list, index, item, e){ var rec = list.store.data.get(index); var image = e.getTarget("img"); if(image){ alert("image clicked"); } } }
-
16 Nov 2010 5:38 AM #3
Did anyone tried this.
Seems all are busy at conference
i used to try something like this before
Code:"itemtap": function(list, index, item, e) { var imageclick = e.getTarget("img"); var rec = list.store.data.get(index); if(imageclick){ alert("Image clicked"); } }
-
21 Dec 2010 6:02 AM #4
I too have this question. In short it's how can I get equivalent of
“itemtap”: function(list, index, item, e)
using the event delegation model described here?
-
12 Feb 2011 2:20 AM #5
did anybody find an elegant solution / answer to Thomas' question?
-
12 Feb 2011 2:34 AM #6
Did you tried
Code:e.getTarget("img");
-
4 Mar 2011 1:47 PM #7
When adding listeners and handlers, is it better to attach something to body or el?
listeners: {
body: { // or el
delegate: ['div.mini_left img', 'div.mini_right img', 'div.mini_single img'],
tap: function(e, t){
// do something
}
}}
Also, whats the best way to handle capturing multiple events and assigning different delegates to them?
Currently I'm using the following solution but it has some performance problems.
// This has to capture a tap event application wide
panelObj.body.on({
tap: function(e, t) {
// do something
}});
// this has to capture double tap only on specific images
panelObj.body.on({
delegate: ['img.abc1', 'img.abc2'],
doubletap: function(e, t) {
// do something else
}});
-
4 Jun 2011 1:00 AM #8
After having done some tests, there seems to be no noticeable improvements over 'onitemtap'.
-
4 Jun 2011 11:42 AM #9
I have done something like this:
Once you get the index you can use the store to get the dataCode:var list = new Ext.List({ tpl: '<tpl for="."><li><img id="{#}" src="{avatar}" /><h1>{name}</h1></li></tpl>', listeners: { el: { tap: function(item){ var index = item.target.id-1; console.log("index is: "+index); }, delegate: 'img' } } });
-
4 Jun 2011 1:46 PM #10
@tolbahady
Just watch out. Your argument isn't an item, it's an EventObject.
Similar Threads
-
When to use event delegation?
By dolittle in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 4 Nov 2008, 9:35 AM -
what is event delegation?
By illuminum in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 28 Jun 2008, 4:57 PM -
Click Delegation Help
By thejoker101 in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 13 Jan 2007, 11:54 PM -
YUI Question : Event Delegation
By INeedADip in forum Ext 1.x: Help & DiscussionReplies: 4Last Post: 23 Oct 2006, 2:08 PM


Reply With Quote