PDA

View Full Version : on click event example



gvorster
26 Sep 2010, 3:20 AM
I'm just starting with Sencha Touch.

If I have this:



<p id='p1'>p1</p>
<p>p2</p>
<p>p3</p>
How can I set an onclick event on all <p>


This works:



Ext.get('p1').on('click', function(){
alert("You clicked p1");
});

This doesn't:


Ext.get('p').on('click', function(){
alert("You clicked a p");
});

jay@moduscreate.com
26 Sep 2010, 2:32 PM
Ext.get is like document.getElementById on steroids. The second example didn't work because you don't have any P tags with the id of 'p'

evant
26 Sep 2010, 7:30 PM
get() is used to return a reference to a single element. You want Ext.select.