How to detect clicks inside of a checkbox?

How to detect clicks inside of a checkbox?

AndersBranderudAndersBranderud Posts: 4Questions: 0Answers: 0
edited May 2011 in General
Hello!

I would like to detect if the user clicked inside of a checkbox. I know how to detect if an user clicked on a certain row. I do it through the below code (I took example code from the website and modified it a little).
I know how to do it in the ordinary way, but would like to know how to do it with Datatables (i.e. set a onclick-attribute on each checkbox).

I know that it is detected when I do: #usersTable tbody tr input .. instead of the below. When these clicks are detected I want to extract the first value of the same row and put it into an array.

Here is the website: http://www.abitsolutions.org/_adminInterface.html

[code]
$('#usersTable tbody tr').live('click',function () {
var aData = oTable.fnGetData( this );
var iId = aData[0];

if ( jQuery.inArray(iId, gaiSelected) == -1 )
{
gaiSelected[gaiSelected.length++] = iId;
}
else //(jQuery.inArray(iId, gaiSelected) == 0) //User unchecked checkbox.
{
var idx = gaiSelected.indexOf(iId); // Find the index
if (idx!=-1) gaiSelected.splice(idx, 1); // Remove it if really found
}

$(this).toggleClass('row_selected');
}); //end of .live

[/code]

Thanks!
Anders Branderud

Replies

  • 28.vivek.s28.vivek.s Posts: 69Questions: 0Answers: 0
    edited May 2011
    i think you need to learn jquery a little bit, your question is related to jquery not to datatable..but for your refrence
    see this discussion...http://datatables.net/forums/comments.php?DiscussionID=4142&page=1#Item_5
This discussion has been closed.