Fix fnSetFilteringDelay when filtering disabled

Adds a check to fnSetFilteringDelay() that the table actually has the search box enabled - previously calling fnSetFilteringDelay() for a table without filtering would hijack ALL the search input box 'keyup' bindings on the whole page.
pull/293/head
Michael Fielding 8 years ago committed by GitHub
parent a7ba2feda5
commit 8932d269b7

@ -29,25 +29,28 @@ jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay )
} }
this.each( function ( i ) { this.each( function ( i ) {
$.fn.dataTableExt.iApiIndex = i; if ( typeof _that.fnSettings().aanFeatures.f !== 'undefined' )
var {
oTimerId = null, $.fn.dataTableExt.iApiIndex = i;
sPreviousSearch = null, var
anControl = $( 'input', _that.fnSettings().aanFeatures.f ); oTimerId = null,
sPreviousSearch = null,
anControl.unbind( 'keyup search input' ).bind( 'keyup search input', function() { anControl = $( 'input', _that.fnSettings().aanFeatures.f );
if (sPreviousSearch === null || sPreviousSearch != anControl.val()) { anControl.unbind( 'keyup search input' ).bind( 'keyup search input', function() {
window.clearTimeout(oTimerId);
sPreviousSearch = anControl.val(); if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
oTimerId = window.setTimeout(function() { window.clearTimeout(oTimerId);
$.fn.dataTableExt.iApiIndex = i; sPreviousSearch = anControl.val();
_that.fnFilter( anControl.val() ); oTimerId = window.setTimeout(function() {
}, iDelay); $.fn.dataTableExt.iApiIndex = i;
} _that.fnFilter( anControl.val() );
}); }, iDelay);
}
return this; });
return this;
}
} ); } );
return this; return this;
}; };

Loading…
Cancel
Save