Sorting by Date / Time in Safari or Firefox
Sorting by Date / Time in Safari or Firefox
Hi all
I am having issues with DataTables using Moment.js but only in Safari or Firefox.
I have a table located at http://www.scarboroughcricketclub.co.uk/cricket/scc-match-information I have links (in this order) to the various scripts needed:
//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js
//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js
//cdn.datatables.net/plug-ins/1.10.7/sorting/datetime-moment.js
//cdn.datatables.net/1.10.7/css/jquery.dataTables.css
I also have a link to a local JavaScript file containing the following:
jQuery(document).ready(function($) {
$.fn.dataTable.moment( 'ddd D MMMM YYYY, HH:mm' );
$('.table-fixtures').DataTable({
"paging": false,
columnDefs: [
{ targets: 'no-sort', orderable: false }
]
});
});
The table should sort by date. This works in Chrome but not in Safari or Firefox. Other columns sort with no problems in all browsers, I am just having problems with the dates. If anyone can shed any light on what I am doing wrong then I would greatly appreciate it.
Thank you
Answers
I have moved the jQuery snippet above from an external file and placed it in the page but this doesn't help either.
It seems the problem is with some invalid dates in the table. For example if one of the dates in the table has the format "TBC TBC July 2015, 13:00" then it breaks the whole date/time sorting.
Therefore, is there a way to discount invalid dates?