0
|
1 // DATA_TEMPLATE: empty_table
|
|
2 oTest.fnStart( "fnDrawCallback" );
|
|
3
|
|
4 /* Fairly boring function compared to the others! */
|
|
5
|
|
6 $(document).ready( function () {
|
|
7 /* Check the default */
|
|
8 var oTable = $('#example').dataTable( {
|
|
9 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
10 "bDeferRender": true
|
|
11 } );
|
|
12 var oSettings = oTable.fnSettings();
|
|
13 var mPass, bInit;
|
|
14
|
|
15 oTest.fnWaitTest(
|
|
16 "Default should be null",
|
|
17 null,
|
|
18 function () { return oSettings.fnDrawCallback == null; }
|
|
19 );
|
|
20
|
|
21
|
|
22 oTest.fnWaitTest(
|
|
23 "One argument passed",
|
|
24 function () {
|
|
25 oSession.fnRestore();
|
|
26
|
|
27 mPass = -1;
|
|
28 bInit = false;
|
|
29 $('#example').dataTable( {
|
|
30 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
31 "bDeferRender": true,
|
|
32 "fnDrawCallback": function ( ) {
|
|
33 mPass = arguments.length;
|
|
34 },
|
|
35 "fnInitComplete": function () {
|
|
36 bInit = true;
|
|
37 }
|
|
38 } );
|
|
39 },
|
|
40 function () { return mPass == 1 && bInit; }
|
|
41 );
|
|
42
|
|
43
|
|
44 oTest.fnWaitTest(
|
|
45 "That one argument is the settings object",
|
|
46 function () {
|
|
47 oSession.fnRestore();
|
|
48
|
|
49 bInit = false;
|
|
50 oTable = $('#example').dataTable( {
|
|
51 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
52 "bDeferRender": true,
|
|
53 "fnDrawCallback": function ( oSettings ) {
|
|
54 mPass = oSettings;
|
|
55 },
|
|
56 "fnInitComplete": function () {
|
|
57 bInit = true;
|
|
58 }
|
|
59 } );
|
|
60 },
|
|
61 function () { return oTable.fnSettings() == mPass && bInit; }
|
|
62 );
|
|
63
|
|
64
|
|
65 /* The draw callback is called once for the init and then when the data is added */
|
|
66 oTest.fnWaitTest(
|
|
67 "fnRowCallback called once on first draw",
|
|
68 function () {
|
|
69 oSession.fnRestore();
|
|
70
|
|
71 mPass = 0;
|
|
72 bInit = false;
|
|
73 $('#example').dataTable( {
|
|
74 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
75 "bDeferRender": true,
|
|
76 "fnDrawCallback": function ( ) {
|
|
77 mPass++;
|
|
78 },
|
|
79 "fnInitComplete": function () {
|
|
80 bInit = true;
|
|
81 }
|
|
82 } );
|
|
83 },
|
|
84 function () { return mPass == 2 && bInit; }
|
|
85 );
|
|
86
|
|
87 oTest.fnWaitTest(
|
|
88 "fnRowCallback called once on each draw there after as well",
|
|
89 function () {
|
|
90 $('#example_next').click();
|
|
91 $('#example_next').click();
|
|
92 $('#example_next').click();
|
|
93 },
|
|
94 function () { return mPass == 5; }
|
|
95 );
|
|
96
|
|
97
|
|
98
|
|
99
|
|
100
|
|
101 oTest.fnComplete();
|
|
102 } ); |