View Full Version : on click event example

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

If I have this:

<p id='p1'>p1</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");

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'

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