From 9e7942b821c7c551115e8917664f212a563468ef Mon Sep 17 00:00:00 2001 From: Wesley Ribeiro Date: Fri, 29 Jan 2016 10:11:14 -0800 Subject: [PATCH] Sorting does not work properly on columns with empty dates inside HTML tags. --- sorting/datetime-moment.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sorting/datetime-moment.js b/sorting/datetime-moment.js index ce5c197..2b255c5 100644 --- a/sorting/datetime-moment.js +++ b/sorting/datetime-moment.js @@ -50,9 +50,12 @@ $.fn.dataTable.moment = function ( format, locale ) { // Add sorting method - use an integer for the sorting types.order[ 'moment-'+format+'-pre' ] = function ( d ) { + if ( d && d.replace ) { + d = d.replace(/<.*?>/g, ''); + } return d === '' || d === null ? -Infinity : - parseInt( moment( d.replace ? d.replace(/<.*?>/g, '') : d, format, locale, true ).format( 'x' ), 10 ); + parseInt( moment( d, format, locale, true ).format( 'x' ), 10 ); }; };