weird error - fnAddData is not a function
weird error - fnAddData is not a function
mamady
Posts: 5Questions: 2Answers: 0
I am getting a weird error where the dataTable() function seems to not return the correct object (I think?).
I have tried it with 1.8.2 and 1.9 - both give the exact same results.
I cant run any functions on the return value of dataTable(). For example, the below code fails:
[code]
var rTable = $('#reportdata').dataTable({
"oLanguage": {
"sEmptyTable": "No broken links found...",
"sLengthMenu": "Show entries: _MENU_"
},
"sDom": '<"top"lf<"clear">>rt<"actions"<"actions-left"i><"actions-right"p>>',
"sPaginationType": "full_numbers"
});
rTable.fnDestroy();
[/code]
The error firebug gives me is:
rTable.fnDestroy is not a function
The table itself is rendering fine, but when I try to use any function on it, I cant. The only one i really need is fnAddData() so I can add rows.
Any thoughts on this? I have been pulling my hair out for about 7 hours now. I suspect it's a fault on my end, Im just wondering if anyone else has come across this before?
I have tried it with 1.8.2 and 1.9 - both give the exact same results.
I cant run any functions on the return value of dataTable(). For example, the below code fails:
[code]
var rTable = $('#reportdata').dataTable({
"oLanguage": {
"sEmptyTable": "No broken links found...",
"sLengthMenu": "Show entries: _MENU_"
},
"sDom": '<"top"lf<"clear">>rt<"actions"<"actions-left"i><"actions-right"p>>',
"sPaginationType": "full_numbers"
});
rTable.fnDestroy();
[/code]
The error firebug gives me is:
rTable.fnDestroy is not a function
The table itself is rendering fine, but when I try to use any function on it, I cant. The only one i really need is fnAddData() so I can add rows.
Any thoughts on this? I have been pulling my hair out for about 7 hours now. I suspect it's a fault on my end, Im just wondering if anyone else has come across this before?
This discussion has been closed.
Replies
Can you link to your demo page that shows the problem please?
Allan
Just for anyone else that comes across this in the future...
The issue was that there is some type of clash between my other javascript libraries and datatables. I dont know which other js lib was causing the problem (I am using quite a few), but the fix was to move the datatables.js include file to be the last file that is loaded - this fixed the problem. No js code changes needed!
Alan, I speak for everyone when I say your support is awesome. Thank you so much. Some of us thank you in silence, others thank you explicitly; but everyone appreciates your great support.
Thanks again.
Thanks for posting your findings! It sounds like you might have loaded jQuery twice. If you do:
1. jQuery
2. DataTables
3. jQuery
The second jQuery will overwrite the first one (which has DataTables attached to it). Thus you would end up with a jQuery object that doesn't have DataTables available.
Bit frustrating that jQuery doesn't give an error about being loaded twice as it bites a lot of people (me included), but, so it goes...
Allan