Implementation issues
Implementation issues
memorylapse
Posts: 4Questions: 0Answers: 0
I have been assigned a task to rework a web page. After looping through a database, results are returned in table format. I came across DataTables and immediately fell in love with this seemingly simple plugin for the jQuery library (cause am very new to this area). However on implementation, this is proving a lot harder than i imagined.
I have included the scripts:
[code]
[/code]
Initialised the table
[code]
$(function() {
$('table#example').dataTable();
});
[/code]
and included table id, and
I am probably missing something simple. Would anyone have any suggestions?
Many thanks in advance!
I have included the scripts:
[code]
[/code]
Initialised the table
[code]
$(function() {
$('table#example').dataTable();
});
[/code]
and included table id, and
I am probably missing something simple. Would anyone have any suggestions?
Many thanks in advance!
This discussion has been closed.
Replies
you DO need to include jquery first.
[code]
[/code]
but it still wasn't working.
Maybe its important for me to mention that i am using the django framework, with my page being at the end of quite a few extensions. There is a lot of underlaying css within this, would these be proving to be the problem?
Is the table in the DOM when dataTable() is called on it?
CSS won't affect whether or not the script works; it will only affect how it looks (though in some rare cases, you might have accidentally hidden the table with display:none or visibility:hidden).
How do you mean "Is the table in the DOM when dataTable() is called on it?"
It is within the DOM like so:
[code]
$(document).ready(function(){
$(function() {
$('#framemon').dataTable();
});
});
[/code]
What I meant about the table being in the DOM is that you seem to be indicating a different loading order than usual ("initialized the table, and included thead and tbody"). It's probably just the way you said it, but of course the thead and tbody need to be ready before you call dataTable() on the table.
I would open a JavaScript console; certain kinds of warnings can cause problems without necessarily popping up as a 'page error'.
There is a problem with this code:
[code]
$(document).ready(function(){
$(function() {
$('#framemon').dataTable();
});
});
[/code]
$(function(){}) is just another shorthand for $(document).ready(function(){}) so I can't imagine it would work, but it might. Either way, you should eliminate the redundancy:
[code]
$(function() {
$('#framemon').dataTable();
});
[/code]