Search code examples
jquery-pluginshtml-tableexternaldatatablestablesorter

Why is my jQuery DataTable plugin not working as desired?


In response to my question here, I was referred to "jquery datatables plugin" which (I think) I found, but which link is not allowed here for some reason.

However, although I added the requisite libraries (one jQuery and one CSS) as "External Resources" to my jsfiddle here and am using precisely the same HTML and jQuery as on their sample page:

$(document).ready(function() {
    $('#example').dataTable( {
        columnDefs: [ {
            targets: [ 0 ],
            orderData: [ 0, 1 ]
        }, {
            targets: [ 1 ],
            orderData: [ 1, 0 ]
        }, {
            targets: [ 4 ],
            orderData: [ 4, 0 ]
        } ]
    } );
} );

...running it doesn't seem to make the table sortable.

What am I missing?

I was also referred to "jQuery Table Sorter" but it doesn't seem to be available on a CDN, and thus would not be available on a jsfiddle page.

UPDATE

Actually, the aforementioned "jQuery Table Sorter" does seem to be available on a CDN, as Jason points out at the other question but, now that I've gotten the other working, I reckon I'll stick with it.


Solution

  • My bad: in my ignorance of CDN reference standards, I assumed the leading double whacks were unnecessary and removed them when adding to the External Resources. IOW, instead of pasting this:

    cdn.datatables.net/1.10.0/js/jquery.dataTables.js
    

    ...it needs to be this:

    //cdn.datatables.net/1.10.0/js/jquery.dataTables.js
    

    On reinstating the double-whacks (which looked like they were being commented out to me), it all runs fine now here