| 1 |
// DATA_TEMPLATE: empty_table |
| 2 |
oTest.fnStart( "fnInitComplete" ); |
| 3 |
|
| 4 |
/* Fairly boring function compared to the others! */ |
| 5 |
|
| 6 |
$(document).ready( function () { |
| 7 |
oTest.fnWaitTest( |
| 8 |
"Two arguments passed", |
| 9 |
function () { |
| 10 |
|
| 11 |
mPass = -1; |
| 12 |
$('#example').dataTable( { |
| 13 |
"bServerSide": true, |
| 14 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 15 |
"fnInitComplete": function ( ) { |
| 16 |
mPass = arguments.length===2 && arguments[1]===undefined; |
| 17 |
} |
| 18 |
} ); |
| 19 |
}, |
| 20 |
function () { return mPass; } |
| 21 |
); |
| 22 |
|
| 23 |
|
| 24 |
oTest.fnWaitTest( |
| 25 |
"That one argument is the settings object", |
| 26 |
function () { |
| 27 |
oSession.fnRestore(); |
| 28 |
|
| 29 |
oTable = $('#example').dataTable( { |
| 30 |
"bServerSide": true, |
| 31 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 32 |
"fnInitComplete": function ( oSettings ) { |
| 33 |
mPass = oSettings; |
| 34 |
} |
| 35 |
} ); |
| 36 |
}, |
| 37 |
function () { console.log( oTable.fnSettings(), mPass );return oTable.fnSettings() === mPass; } |
| 38 |
); |
| 39 |
|
| 40 |
|
| 41 |
oTest.fnWaitTest( |
| 42 |
"fnInitComplete called once on first draw", |
| 43 |
function () { |
| 44 |
oSession.fnRestore(); |
| 45 |
|
| 46 |
mPass = 0; |
| 47 |
$('#example').dataTable( { |
| 48 |
"bServerSide": true, |
| 49 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 50 |
"fnInitComplete": function ( ) { |
| 51 |
mPass++; |
| 52 |
} |
| 53 |
} ); |
| 54 |
}, |
| 55 |
function () { return mPass == 1; } |
| 56 |
); |
| 57 |
|
| 58 |
oTest.fnWaitTest( |
| 59 |
"fnInitComplete never called there after", |
| 60 |
function () { |
| 61 |
$('#example_next').click(); |
| 62 |
$('#example_next').click(); |
| 63 |
$('#example_next').click(); |
| 64 |
}, |
| 65 |
function () { return mPass == 1; } |
| 66 |
); |
| 67 |
|
| 68 |
|
| 69 |
oTest.fnWaitTest( |
| 70 |
"10 rows in the table on complete", |
| 71 |
function () { |
| 72 |
oSession.fnRestore(); |
| 73 |
|
| 74 |
mPass = 0; |
| 75 |
$('#example').dataTable( { |
| 76 |
"bServerSide": true, |
| 77 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 78 |
"fnInitComplete": function ( ) { |
| 79 |
mPass = $('#example tbody tr').length; |
| 80 |
} |
| 81 |
} ); |
| 82 |
}, |
| 83 |
function () { return mPass == 10; } |
| 84 |
); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
oTest.fnComplete(); |
| 89 |
} ); |