我试图让我的数据表的日期范围选择器工作,并且我从这段代码收到错误。我该怎么做才能解决推送错误?从我读到的,最常见的修复是添加一个document.ready调用代码。但我仍然收到错误。它目前没有工作,所以我希望这可以解决我的问题。我该如何解决这个问题?
Uncaught TypeError: Cannot read property 'push' of undefined
at eval (eval at <anonymous> (jquery-1.12.4.min.js:2), <anonymous>:77:35)
at eval (<anonymous>)
at jquery-1.12.4.min.js:2
at Function.globalEval (jquery-1.12.4.min.js:2)
at Ha (jquery-1.12.4.min.js:3)
at e.fn.init.append (jquery-1.12.4.min.js:3)
at e.fn.init.<anonymous> (jquery-1.12.4.min.js:3)
at Y (jquery-1.12.4.min.js:3)
at e.fn.init.html (jquery-1.12.4.min.js:3)
at Object.success (apps.js:732)
代码:
$(document).ready(function(){
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
if (dd<10)
dd = '0'+dd;
if (mm<10)
mm = '0'+mm;
today = mm+'/'+dd+'/'+yyyy;
if ($('#min').val() != '' || $('#max').val() != '') {
var iMin_temp = $('#min').val();
if (iMin_temp == '') {
iMin_temp = '01/01/1980';
}
var iMax_temp = $('#max').val();
if (iMax_temp == '') {
iMax_temp = today;
}
var arr_min = iMin_temp.split("/");
var arr_max = iMax_temp.split("/");
var arr_date = aData[1].split("/");
var iMin = new Date(arr_min[2], arr_min[0], arr_min[1], 0, 0, 0, 0);
var iMax = new Date(arr_max[2], arr_max[0], arr_max[1], 0, 0, 0, 0);
var iDate = new Date(arr_date[2], arr_date[0], arr_date[1], 0, 0, 0, 0);
if ( iMin == "" && iMax == "" )
{
return true;
}
else if ( iMin == "" && iDate < iMax )
{
return true;
}
else if ( iMin <= iDate && "" == iMax )
{
return true;
}
else if ( iMin <= iDate && iDate <= iMax )
{
return true;
}
return false;
}
}
);
$(function() {
$( "#min" ).datepicker();
});
$(function() {
$( "#max" ).datepicker();
});
var oTable=$('#data-table').dataTable();
/* Add event listeners to the two date-range filtering inputs */
$('#min').change( function() { oTable.draw( false ); } );
$('#max').change( function() { oTable.draw( false ); } );
});