$(document).ready(function() script only processes the first page of dataTable
$(document).ready(function() script only processes the first page of dataTable
I have a code like this on my page
$(document).ready(function() {
$("td.offset").each(function(){
DOSOMETHING
});
});
I have about 50 entries in my table, but page only loads 10 at a time.To see next 10 one presses Next and that is where the problem is.
The above script is not applied to td's on that page. Please share the wisdom on how to fix this Thank you in advance.
$(document).ready(function() {
$("td.offset").each(function(){
DOSOMETHING
});
});
I have about 50 entries in my table, but page only loads 10 at a time.To see next 10 one presses Next and that is where the problem is.
The above script is not applied to td's on that page. Please share the wisdom on how to fix this Thank you in advance.
This discussion has been closed.
Replies
[code]
var oTable = $('#someTableID').datatable({
// some initialization variables
// add code below here
});
[/code]
Move the .each code to this:
[code]
"fnDrawCallback":function(oSettings){
$("td.offset").each(function(){
DOSOMETHING
});
},
[/code]
So it should look like this for example now:
[code]
var oTable = $('#someTableID').datatable({
"sDom": 'l<"clear">ript',
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "index.php",
"sPaginationType": "full_numbers",
"fnDrawCallback":function(oSettings){
$("td.offset").each(function(){
DOSOMETHING
});
}
});
[/code]
Your code that you have now isn't being called with each call, its only being called on the initial page load, you need to move it like I called so its called on each load of datatables.