fnRowCallback and IE8
fnRowCallback and IE8
I'm using fnRowCallback to add onmouseover, onmouseout and onclick events to rows in a DataTables table. This works fine in Firefox, but in IE the callbacks never fire. I've checked the code in IE's developer tools, and the callback declarations are correctly inserted into the DOM, and if I take the generated code and view that in IE it works (ie, copy/paste the generated table source into a separate HTML doc).
Does anyone have any ideas why IE is behaving in this way?
Here's the DataTables / event callback code I'm using...
[code]
function ChangeColor(tableRow, highLight) {
if (highLight) {
tableRow.style.backgroundColor = '#dcfac9';
}
else {
tableRow.style.backgroundColor = 'white';
}
}
function DoNav(theUrl) {
document.location.href = theUrl;
}
...
$(document).ready(function(){
oTable = $("#assettable").dataTable( {
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
url = "DoNav('/objects/" + aData[6] + "/');";
$(nRow).attr({"onmouseover":"ChangeColor(this, true);", "onmouseout":"ChangeColor(this, false);", "onclick": url});
return nRow;
},
"bAutoWidth" : false,
"aoColumns" : [
{ "sWidth" : "90px" },
{ "sWidth" : "190px" },
{ "sWidth" : "95px" },
{ "sWidth" : "85px" },
{ "sWidth" : "270px" },
{ "sWidth" : "70px" },
{ "bVisible": false }
],
"bProcessing": true,
"bServerSide": true,
"bSortClasses": false,
"sPaginationType": "full_numbers",
"iDisplayLength": 20,
"sDom": 'rt<"bottom"ip<"clear">',
"sAjaxSource": "/ajax/objectlist/",
"fnServerData": function ( eSource, aoData, fnCallback ) {
$.getJSON(eSource, aoData, function(json) {
fnCallback(json);
});
}
});
[/code]
Does anyone have any ideas why IE is behaving in this way?
Here's the DataTables / event callback code I'm using...
[code]
function ChangeColor(tableRow, highLight) {
if (highLight) {
tableRow.style.backgroundColor = '#dcfac9';
}
else {
tableRow.style.backgroundColor = 'white';
}
}
function DoNav(theUrl) {
document.location.href = theUrl;
}
...
$(document).ready(function(){
oTable = $("#assettable").dataTable( {
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
url = "DoNav('/objects/" + aData[6] + "/');";
$(nRow).attr({"onmouseover":"ChangeColor(this, true);", "onmouseout":"ChangeColor(this, false);", "onclick": url});
return nRow;
},
"bAutoWidth" : false,
"aoColumns" : [
{ "sWidth" : "90px" },
{ "sWidth" : "190px" },
{ "sWidth" : "95px" },
{ "sWidth" : "85px" },
{ "sWidth" : "270px" },
{ "sWidth" : "70px" },
{ "bVisible": false }
],
"bProcessing": true,
"bServerSide": true,
"bSortClasses": false,
"sPaginationType": "full_numbers",
"iDisplayLength": 20,
"sDom": 'rt<"bottom"ip<"clear">',
"sAjaxSource": "/ajax/objectlist/",
"fnServerData": function ( eSource, aoData, fnCallback ) {
$.getJSON(eSource, aoData, function(json) {
fnCallback(json);
});
}
});
[/code]
This discussion has been closed.
Replies