fnDrawCallback, the table isn't rendered yet
fnDrawCallback, the table isn't rendered yet
I have an mRender for one of my columns that has the format "%s". When I attempt to retrieve $('.jTip') in fnDrawCallback, it never finds anything. After the last fnDrawCallback, the table is finally displayed, and $('.jTip') finds all the items it should. Is this expected behavior? I thought fnDrawCallback gets called after the entire table is in the DOM.
This discussion has been closed.
Replies
bJQueryUI: false, //themeroller support
bStateSave: true, //save sort state across F5 screen refresh
bPaginate: false,
sScrollY: fnCalcDataTableHeight(305),
"sScrollX": "100%",
"bScrollCollapse": true,
bInfo: false,
bFilter: false,
bAutoWidth: true,
aoColumnDefs: [
{
aTargets: [0],
bSortable: true,
sWidth: "30px",
sType: "numeric"
},
{
aTargets: [1],
bSortable: true,
sWidth: "280px",
mRender: function (data, type, row) {
var linkFormat = "%s";
var col1Parts = data.split(";");
var formattedValues = vsprintf(linkFormat, col1Parts);
return formattedValues;
}
},
{
aTargets: ["_all"],
sWidth: "175px",
bSortable: false,
}
],
bSortClasses: false, //disable the highlighting of the sort column
bProcessing: false,
sAjaxSource: url,
fnRowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td', nRow).each(function (index) {
var that = $(this);
var inner = aData[index + 2];
that.empty();
var parts = inner.split(';');
that.attr('data-s', parts[0]);
that.attr('data-d', parts[1]);
that.attr('title', parts[2]);
that.addClass('statusCell');
});
},
fnInitComplete: function () {
postInitializeTable();
}
});[/code]
I renamed fnDrawCallback to fnInitComplete. It works on the first call, but I want it to happen every time I do an ajax refresh, just after all the dom elements are available to jQuery.
Use `this.$('.jTip')...` in fnInitComplete to get all of the elements - see: http://datatables.net/docs/DataTables/1.9.4/#$
Allan