Datatable not responding!! fixed by ALERT! What?!

Datatable not responding!! fixed by ALERT! What?!

SpreADXSpreADX Posts: 8Questions: 0Answers: 0
edited March 2014 in General
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!!

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Remember what the `a` in ajax stands for! The problem is that your function on line 33 is being executed before the data has been loaded.

    Use fnInitComplete to run code once the data has been loaded.

    Allan
This discussion has been closed.