-
-
Save jameshandsoame/014af0a61d007df92b018a6353a9fac2 to your computer and use it in GitHub Desktop.
Revisions
-
Sam X created this gist
Jun 23, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ jQuery.fn.dataTableExt.oApi.fnSetFilterDebounce = function ( oSettings, iDelay ) { /* * Type: Plugin for DataTables (www.datatables.net) JQuery plugin. * Name: dataTableExt.oApi.fnSetFilterDebounce * Version: 0.01 * Description: Enables filtration debouncing which prevents filter from * happening until keypresses have stopped for [iDelay] milliseconds. * Uses code from Zygimantas' fnSetFilteringDelay * Inputs: object:oSettings - dataTables settings object * integer:iDelay - delay in miliseconds * Returns: JQuery * Usage: $('#example').dataTable().fnSetFilterDebounce(250); * Requires: DataTables 1.6.0+, Underscore.js 1.1.3+ * * Author: Sam X Nguyen, Zygimantas Berziunas (www.zygimantas.com) * and Allan Jardine (v2) * Created: June 23, 2011 * Language: Javascript * License: GPL v2 or BSD 3 point style * Contact: [email protected] */ var _that = this; this.each( function ( i ) { $.fn.dataTableExt.iApiIndex = i; var iDelay = (iDelay && (/^[0-9]+$/.test(iDelay)) ? iDelay : 250), $this = this, oTimerId = null, sPreviousSearch = null, anControl = $( 'input', _that.fnSettings().aanFeatures.f ); var fnFilter = function() { _that.fnFilter( anControl.val() ); } anControl.unbind( 'keyup' ).bind( 'keyup', _(fnFilter).debounce(iDelay) ); return this; } ); return this; }