-
20 Aug 2010 4:10 AM #1
Tap or click event for image in Panel
Tap or click event for image in Panel
I want something, i would think, reasonable simple namely; doing something when an image in a panel (or the panel itself) is clicked or tapped. Somehow it's not working though...
Context: a carrousel with three images per card (which i stuck in panels) that should each open an overlay with a video when clicked. I have my application layed out. I can do overlays, carrousels and video. But i can't get the d*mn click event to fire...
I've tried for instance:
neither events fire since i guess Panel has neither event bubbling up. So then i tried:Code:var look = new Ext.Panel({ id: name, cls: 'look', html: '<img src="content/images/' + image + '"></img>', listeners: { single: true, click: function(){ console.debug('click'); }, tap: function(){ console.debug('tap'); } } });
but no luck there either. i even tried adding a plugin to the panel that defines a DomObserver along the lines of the example in the docs but i couldn't get that to work, and it seemed overly complex for something simple anyway...Code:look.on('click', function(){ console.log('hi'); //return false; }, null, {delegate: 'img'});
What should i try next?
-
20 Aug 2010 6:03 AM #2
Cool i think i figured it out. This lazy rendering thing was really tripping me up, requires another way of thinking i guess. but... The following seems to work as advertised:
Now if there is a cleaner/better way to achieve this please let me know!Code:var look = new Ext.Panel({ id: name, cls: 'look', html: '<img src="content/images/' + image + '"></img>', afterRender: function() { Ext.Panel.superclass.afterRender.apply(this, arguments); Ext.EventManager.on(this.id, 'click', function() { console.debug("clicked!"); }); }, });
-
20 Aug 2010 10:00 PM #3
Quicker:
In future we're going to add the ability to bind dom level events on components directly via the listeners config, so stay tuned.Code:new Ext.Panel({ listeners: { afterrender: function(c){ c.el.on('click', function(){}); } } });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
21 Aug 2010 1:11 AM #4
Great news!
I would also love to see more tutorials in the spirit of the latest data and infinite carrousel posts. Something like the howtonode site was doing for instance. When your not coming from Ext.js a lot of this stuff is completely foreign while the documentation examples at least seem to expect some kind of basic understanding of the way stuff is done here.
-
18 Sep 2011 11:38 PM #5
test
test
var look = new Ext.Panel({ id: name, cls: 'look', html: '<img src="content/images/' + image + '"></img>', listeners: { el:{ tap:function(e){ alert('click'); } } }});
Similar Threads
-
[SOLVED] Dataview display some image - on event click how to know which image ?
By Etienne Jouvin in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 7 Feb 2011, 4:46 AM -
Tap/Click listener on an element in Tab Items
By pennyroyal in forum Sencha Touch 1.x: DiscussionReplies: 6Last Post: 17 Aug 2010, 7:55 AM -
image click event
By anoop abbot in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 21 Apr 2009, 1:10 AM -
display an image with click event in a panel
By vamsee24 in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 19 Feb 2009, 5:50 AM -
Image click event
By nheminge in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 13 Dec 2007, 8:09 PM


Reply With Quote
