Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
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

 Answers
20

fnAddData and fnGetNodes are no longer functions (which is exactly what your error says)



See https://datatables.net/upgrade/1.10-convert


[#44708] Saturday, June 7, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deanna

Total Points: 84
Total Questions: 86
Total Answers: 107

Location: Cyprus
Member since Wed, Dec 8, 2021
3 Years ago
;