onclick on an iPad?

onclick on an iPad?

mattgalvinmattgalvin Posts: 2Questions: 0Answers: 0
edited June 2012 in General
I've got a datatable where I have tr click handler that is working fine on various browsers on a computer. On an iPad, the onClick doesn't fire. I've found information that points to a bug in the mobile Safari implementation as well as a workaround (http://blog.alanszlosek.com/post/4369588562/jquerys-live-click-handler-on-mobile-safari).

According to the workaround, I need the tr element to include [code]onclick=""[/code] in the rendered html, but I can't figure out how to get datatables to do that.

The datatables config is:

[code]

var aTable = $('#notifications').dataTable({
bProcessing: true,
bServerSide: true,
bLengthChange: false,
iDisplayLength: 10,
aoColumnDefs: [
{ "bVisible": false, "aTargets": [0] },
{ "bSearchable": false, "aTargets": [ 0, 1 ] },
{ "bSortable": false, "aTargets": [ 0, 2, 3, 4, 5 ] }
],
sAjaxSource: '/myURL'}'
});

$('#notifications tbody tr').live('click',function(event){
var aData = aTable.fnGetData(this);
var link = "/anotherURL/" + aData[0];
$.colorbox({
href:link,
iframe:true,
scrolling:false,
});
});
} );
[/code]

Can anyone help?

Replies

  • mattgalvinmattgalvin Posts: 2Questions: 0Answers: 0
    Solution was simple enough.. Added this to the dataTable definition:

    [code]
    fnCreatedRow: function( nRow, aData, iDataIndex ) {
    nRow.setAttribute("onclick", "");
    },
    [/code]
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    That's interesting - I'm not sure why your live function wouldn't have worked - however, good to hear you have a workaround. Thanks for sharing it with us!

    Allan
This discussion has been closed.