Joni de Campos
Posts: 0
Joined: Fri Dec 11, 2015 12:21 pm

Finding which button was clicked on a list using a element.on("click",function() listener

I have a page with alist or a grid that contains 2 buttons on each cell.

I am using a listener to find out when a user click on the cell, but what I need to have is to check which buttton on the cell was pressed...

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Finding which button was clicked on a list using a element.on("click",function() listener

Hello Joni,

You can get the button, wich was clicked with JS below:
prevar button = event.target;/pre

Joni de Campos
Posts: 0
Joined: Fri Dec 11, 2015 12:21 pm

Finding which button was clicked on a list using a element.on("click",function() listener

I am getting a "ReferenceError: button is not defined"

Code:

element.on("click",function()

{
var button = event.target; // is not working

//here goes rest of code

}
);

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Finding which button was clicked on a list using a element.on("click",function() listener

It is better to use Appery.io visual builder to add events' handlers instead of custom listeners: https://devcenter.appery.io/documenta...

If you need to use that option - please add parameter event to your function:
preelement.on("click",function(event) {
var button = event.target; // is not working
//here goes rest of code
});/pre

Joni de Campos
Posts: 0
Joined: Fri Dec 11, 2015 12:21 pm

Finding which button was clicked on a list using a element.on("click",function() listener

Thanks Sergiy, I missed the event on function (event).

It worked. Fantastic job !

Return to “Issues”