Datatable not responding!! fixed by ALERT! What?!
Datatable not responding!! fixed by ALERT! What?!
I don't understand why the following code only works if I run an alert ---> alert("alert"); if I delete this line, does not work!! WHAT!!!??
[code]
.....
var oTable = $('#datatableEditExam').dataTable({
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"bRetrieve": true,
"sAjaxSource": base_url() + '/ceditexam/getAllPossibleQuestions',
"fnServerParams": function(aoData) {
aoData.push({"name": "subject", "value": examData[0][0].subject});
},
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayStart ": 20,
"fnInitComplete": function() {
oTable.fnAdjustColumnSizing();
},
'fnServerData': function(sSource, aoData, fnCallback) {
$.ajax
({
'dataType': 'json',
'type': 'POST',
'url': sSource,
'data': aoData,
'success': fnCallback
});
}
});
alert("alert");
$(oTable.fnGetNodes()).each(function() {
var elemnt = this;
for (var i = 0; i < examData[1].length; i++) {
if(elemnt.id === examData[1][i].questionId){
alert("sssss la kosa va bien");
}
}
alert("input");
});
[/code]
I created the datatable and works fine, after that I try to search through the nodes some checkboxes but if I don't run the alert the .each(function) does not work. If I write the code alert("alert"); works fine... Why? Some help please. Thanks!!
[code]
.....
var oTable = $('#datatableEditExam').dataTable({
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"bRetrieve": true,
"sAjaxSource": base_url() + '/ceditexam/getAllPossibleQuestions',
"fnServerParams": function(aoData) {
aoData.push({"name": "subject", "value": examData[0][0].subject});
},
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayStart ": 20,
"fnInitComplete": function() {
oTable.fnAdjustColumnSizing();
},
'fnServerData': function(sSource, aoData, fnCallback) {
$.ajax
({
'dataType': 'json',
'type': 'POST',
'url': sSource,
'data': aoData,
'success': fnCallback
});
}
});
alert("alert");
$(oTable.fnGetNodes()).each(function() {
var elemnt = this;
for (var i = 0; i < examData[1].length; i++) {
if(elemnt.id === examData[1][i].questionId){
alert("sssss la kosa va bien");
}
}
alert("input");
});
[/code]
I created the datatable and works fine, after that I try to search through the nodes some checkboxes but if I don't run the alert the .each(function) does not work. If I write the code alert("alert"); works fine... Why? Some help please. Thanks!!
This discussion has been closed.
Replies
Use fnInitComplete to run code once the data has been loaded.
Allan