1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
// DATA_TEMPLATE: empty_table
oTest.fnStart( "Cell invalidation" );
$(document).ready( function () {
var t = $('#example').DataTable( {
ajax: "../../../examples/ajax/data/arrays.txt"
} );
oTest.fnWaitTest(
"Cell 1 html is as expected",
null,
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'Airi Satou'; }
);
oTest.fnTest(
"Cell 1 data is as expected",
null,
function () { return t.cell(':eq(0)', 0).data() == 'Airi Satou'; }
);
oTest.fnTest(
"Cell 2 html is as expected",
null,
function () { return $(t.cell(':eq(0)', 1).node()).text() == 'Accountant'; }
);
oTest.fnTest(
"Cell 2 data is as expected",
null,
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; }
);
oTest.fnTest(
"Cell 3 html is as expected",
null,
function () { return $(t.cell(':eq(0)', 2).node()).text() == 'Tokyo'; }
);
oTest.fnTest(
"Cell 3 data is as expected",
null,
function () { return t.cell(':eq(0)', 2).data() == 'Tokyo'; }
);
oTest.fnTest(
"Modify the HTML in cell 2 - cell data hasn't changed",
function () { $('#example tbody tr:eq(0) td:eq(1)').html('html write'); },
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; }
);
oTest.fnTest(
"Modify the data in cell 1 - html updates",
function () { t.cell(':eq(0)', 0).data('allan'); },
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'allan'; }
);
oTest.fnTest(
"And cell 2's content hasn't changed",
null,
function () { return $(t.cell(':eq(0)', 1).node()).text() == 'html write'; }
);
oTest.fnTest(
"And cell 2's data hasn't changed",
null,
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; }
);
oTest.fnTest(
"HTML write to cell 3 - data doesn't change",
function () { $('#example tbody tr:eq(0) td:eq(2)').html('lottie'); },
function () { return t.cell(':eq(0)', 2).data() == 'Tokyo'; }
);
oTest.fnTest(
"Data invalidate cell 3 - data value written to the DOM",
function () { t.cell(':eq(0)', 2).invalidate(); },
function () { return $(t.cell(':eq(0)', 2).node()).text() == 'Tokyo'; }
);
oTest.fnTest(
"And data matches",
null,
function () { return t.cell(':eq(0)', 2).data() == 'Tokyo'; }
);
oTest.fnTest(
"And cell 2's content hasn't changed",
null,
function () { return $(t.cell(':eq(0)', 1).node()).text() == 'html write'; }
);
oTest.fnTest(
"And cell 2's data hasn't changed",
null,
function () { return t.cell(':eq(0)', 1).data() == 'Accountant'; }
);
oTest.fnTest(
"DOM invalidate cell 2 - data has changed",
function () { t.cell(':eq(0)', 1).invalidate('dom'); },
function () { return t.cell(':eq(0)', 1).data() == 'html write'; }
);
oTest.fnTest(
"Change data directly for cell 1 - html not updated",
function () { t.row(':eq(0)').data()[0] = 'archie'; },
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'allan'; }
);
oTest.fnTest(
"Data invalidate cell 1 - data written to dom",
function () { t.cell(':eq(0)', 0).invalidate(); },
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'archie'; }
);
oTest.fnTest(
"Change data directly for cell 1 - again html not updated",
function () { t.row(':eq(0)').data()[0] = 'lottie'; },
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'archie'; }
);
oTest.fnTest(
"HTML invalidate cell 1 - data read from HTML",
function () { t.cell(':eq(0)', 0).invalidate('dom'); },
function () { return t.cell(':eq(0)', 0).data() == 'archie'; }
);
oTest.fnTest(
"And cell content remains",
null,
function () { return $(t.cell(':eq(0)', 0).node()).text() == 'archie'; }
);
oTest.fnComplete();
} );
|