clicks on table rows do not register on iOS devices, simple example provided

clicks on table rows do not register on iOS devices, simple example provided

gnychisgnychis Posts: 9Questions: 0Answers: 0
edited December 2013 in General
I am trying to get a callback when a row is clicked in a DataTable. I have a simple example that works in my desktop browser, and across various browsers on Android (e.g., Chrome, Web, Opera, Firefox). However, when trying the example on two iOS devices that I own, my clicks do not register on rows in the DataTable. I can click on the row headers just fine in iOS, but my data rows do not register clicks:

http://live.datatables.net/arofil

[code]
// Get clicks on table rows
$(document).on('click', '#example tr', function () {
var oTable = $('#example').dataTable();
var iPos = oTable.fnGetPosition(this);
alert("got a click");
if (iPos != null) {
var aData = oTable.fnGetData(iPos);//get data of the clicked row
alert("good");
}
});
[/code]

Does anyone see anything wrong in this simple example, and get the same behavior on their iOS device?

Replies

  • allanallan Posts: 65,409Questions: 1Answers: 10,860 Site admin
    I don't have an iOS device available at the moment, but does it work if you use:

    [code]
    $('#example tbody').on( 'click', 'tr', function () {
    [/code]

    in place of the first line?

    Allan
  • gnychisgnychis Posts: 9Questions: 0Answers: 0
    That worked perfectly, thank you Allan!
  • allanallan Posts: 65,409Questions: 1Answers: 10,860 Site admin
    Excellent - thanks for letting us know!

    Allan
This discussion has been closed.