localeCompare can't get it to work

localeCompare can't get it to work

bpinetbpinet Posts: 2Questions: 1Answers: 0

Hi,
I'm not a programmer but I can put some code together to make it work. I'm struggling wit this one for hours.
I've put this code in header:

jQuery.extend( jQuery.fn.dataTableExt.oSort, {
    "polish-string-asc" : function (s1, s2) {
        return s1.localeCompare(s2);
    },
 
    "polish-string-desc" : function (s1, s2) {
        return s2.localeCompare(s1);
    }
} );

and this is how I run tables:

$(document).ready( function () {
   $('#myTable').DataTable( {
          "autoWidth": false,
          "columns": [
    null,
    null,
    { "orderable": false },
    { "orderable": false }
  ],
columnDefs: [
    { type: 'polish-string', targets: 1 }
  ],
    });
} );

Problem is it does not work at all. I'm using DataTables in WordPress.
Chrome gives me this: "Uncaught TypeError: Cannot read property 'oSort' of undefined".
FireFox gives me this: "TypeError: jQuery.fn.dataTableExt is undefined".

Please help.

Answers

  • bpinetbpinet Posts: 2Questions: 1Answers: 0

    hrefs inside td is the reason thing didn't work. Works fine now.

This discussion has been closed.