CanJS table click event

450 Views Asked by At

I am writing an canJS application and so far successful in handling the click event for an html table. Using the following code.

 'table td click':function(el,event){
        console.log('clicked ',el.text());
     }
  1. How to listen to only first column click for the table instead of whole td?
  2. How to retrieve particular column's data from the td (el)?
1

There are 1 best solutions below

2
On BEST ANSWER

Try this:

'table td:nth-child(1) click'

Possible answer of 2nd question, first handle whole tr:

'table tr:nth-child(1) click':function(el,event){
    console.log(el.find('td').eq(0).html()); // gets first column
 }