155
rated 0 times
[
159]
[
4]
/ answers: 1 / hits: 9848
/ 10 Years ago, mon, june 9, 2014, 12:00:00
I'm new to web development and jquery and cannot work out what I'm doing wrong.
$(document).ready(function() {
/* initialise table */
var oTable = $('#table').DataTable( {
oLanguage: {
sEmptyTable: No data defined!
},
});
/* test */
$('#testbtn').click( function () {
oTable.row('.selected').remove().draw( false );
oTable.fnAddData( [ aa, aa, aa ] ); - throws error
oTable.fnGetNodes().serialize(); - throws error
} );
});
Within document.ready I am initialising my datatable and then setting up a click handler for a button I have on the page.
Within the buttons click handler, the first line works fine. i.e it deleted the selected row from the table.
However the Second line and third line through the following error;
Uncaught TypeError: undefined is not a function
However if I expand out the second two lines to
$('#table').DataTable().fnAddData( [ aa, aa, aa ] );
$('#table').DataTable().fnGetNodes().serialize();
They work fine, the first line adds a row to my table, and the second row whilst its not doing much doesn't through an error anymore.
Any ideas?
Thanks
More From » jquery