Implementation issues

Implementation issues

memorylapsememorylapse Posts: 4Questions: 0Answers: 0
edited September 2011 in General
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!

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    you won't need both js scripts. "min" is just a reduced version (minified, white space taken out, maybe some name substitutinos, but logically identical)

    you DO need to include jquery first.
  • memorylapsememorylapse Posts: 4Questions: 0Answers: 0
    Thanks, though i did have this:
    [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?
  • GregPGregP Posts: 500Questions: 10Answers: 0
    edited September 2011
    If you have a JavaScript console open, is it reporting any errors? Using the console, can you confirm that the scripts are indeed loading?

    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).
  • memorylapsememorylapse Posts: 4Questions: 0Answers: 0
    No i dont have a JavaScript console open. But am not getting any errors when i run my page.

    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]
  • memorylapsememorylapse Posts: 4Questions: 0Answers: 0
    can anyone tell me what version is best to download?
  • GregPGregP Posts: 500Questions: 10Answers: 0
    edited September 2011
    The latest version, of course. ;-)

    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]
This discussion has been closed.