Merge pull request #246 from wesleyer/master

Sorting: Moment date / time sorting does not work properly on columns with empty dates inside HTML tags
pull/249/head
Allan Jardine 9 years ago
commit d106faa7dd

@ -50,9 +50,12 @@ $.fn.dataTable.moment = function ( format, locale ) {
// Add sorting method - use an integer for the sorting // Add sorting method - use an integer for the sorting
types.order[ 'moment-'+format+'-pre' ] = function ( d ) { types.order[ 'moment-'+format+'-pre' ] = function ( d ) {
if ( d && d.replace ) {
d = d.replace(/<.*?>/g, '');
}
return d === '' || d === null ? return d === '' || d === null ?
-Infinity : -Infinity :
parseInt( moment( d.replace ? d.replace(/<.*?>/g, '') : d, format, locale, true ).format( 'x' ), 10 ); parseInt( moment( d, format, locale, true ).format( 'x' ), 10 );
}; };
}; };

Loading…
Cancel
Save