fnSetFilteringDelay found a bug
fnSetFilteringDelay found a bug
Hello, i have posted a modified version of this function, since it sometimes sets byitself my search input(the one on the top right) to "-1"
[code]
jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
/*
* Type: Plugin for DataTables (www.datatables.net) JQuery plugin.
* Name: dataTableExt.oApi.fnSetFilteringDelay
* Version: 2.2.1
* Description: Enables filtration delay for keeping the browser more
* responsive while searching for a longer keyword.
* Inputs: object:oSettings - dataTables settings object
* integer:iDelay - delay in miliseconds
* Returns: JQuery
* Usage: $('#example').dataTable().fnSetFilteringDelay(250);
* Requires: DataTables 1.6.0+
*
* Author: Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine (v2)
* Created: 7/3/2009
* Language: Javascript
* License: GPL v2 or BSD 3 point style
* Contact: zygimantas.berziunas /AT\ hotmail.com
*/
var
_that = this,
iDelay = (typeof iDelay == 'undefined') ? 750 : iDelay;
this.each( function ( i ) {
$.fn.dataTableExt.iApiIndex = i;
var
$this = this,
oTimerId = null,
sPreviousSearch = null,
anControl = $( 'input', _that.fnSettings().aanFeatures.f );
anControl.unbind( 'keyup' ).bind( 'keyup', function() {
var $$this = $this;
if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
window.clearTimeout(oTimerId);
sPreviousSearch = anControl.val();
oTimerId = window.setTimeout(function() {
$.fn.dataTableExt.iApiIndex = i;
if (anControl.val() != '-1')//////////////////////////////////////////added this if
_that.fnFilter( anControl.val() );
}, iDelay);
}
});
return this;
} );
return this;
};
[/code]
i don't understand much this code here, but why does anControl.val() sometimes equals to -1, i end up with the table having the search field = -1 while i did not type it, i lost a lot of time to notice this and to fix this
i basically unhide the table and then redraw it with this code
[code]
$('#tableWrapper').show();
oTable.fnDraw();
[/code]
the bug only happends the first time i do a search
[code]
jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
/*
* Type: Plugin for DataTables (www.datatables.net) JQuery plugin.
* Name: dataTableExt.oApi.fnSetFilteringDelay
* Version: 2.2.1
* Description: Enables filtration delay for keeping the browser more
* responsive while searching for a longer keyword.
* Inputs: object:oSettings - dataTables settings object
* integer:iDelay - delay in miliseconds
* Returns: JQuery
* Usage: $('#example').dataTable().fnSetFilteringDelay(250);
* Requires: DataTables 1.6.0+
*
* Author: Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine (v2)
* Created: 7/3/2009
* Language: Javascript
* License: GPL v2 or BSD 3 point style
* Contact: zygimantas.berziunas /AT\ hotmail.com
*/
var
_that = this,
iDelay = (typeof iDelay == 'undefined') ? 750 : iDelay;
this.each( function ( i ) {
$.fn.dataTableExt.iApiIndex = i;
var
$this = this,
oTimerId = null,
sPreviousSearch = null,
anControl = $( 'input', _that.fnSettings().aanFeatures.f );
anControl.unbind( 'keyup' ).bind( 'keyup', function() {
var $$this = $this;
if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
window.clearTimeout(oTimerId);
sPreviousSearch = anControl.val();
oTimerId = window.setTimeout(function() {
$.fn.dataTableExt.iApiIndex = i;
if (anControl.val() != '-1')//////////////////////////////////////////added this if
_that.fnFilter( anControl.val() );
}, iDelay);
}
});
return this;
} );
return this;
};
[/code]
i don't understand much this code here, but why does anControl.val() sometimes equals to -1, i end up with the table having the search field = -1 while i did not type it, i lost a lot of time to notice this and to fix this
i basically unhide the table and then redraw it with this code
[code]
$('#tableWrapper').show();
oTable.fnDraw();
[/code]
the bug only happends the first time i do a search
This discussion has been closed.
Replies
[code]
jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
/*
* Type: Plugin for DataTables (www.datatables.net) JQuery plugin.
* Name: dataTableExt.oApi.fnSetFilteringDelay
* Version: 2.2.1
* Description: Enables filtration delay for keeping the browser more
* responsive while searching for a longer keyword.
* Inputs: object:oSettings - dataTables settings object
* integer:iDelay - delay in miliseconds
* Returns: JQuery
* Usage: $('#example').dataTable().fnSetFilteringDelay(250);
* Requires: DataTables 1.6.0+
*
* Author: Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine (v2)
* Created: 7/3/2009
* Language: Javascript
* License: GPL v2 or BSD 3 point style
* Contact: zygimantas.berziunas /AT\ hotmail.com
*/
var
_that = this,
iDelay = (typeof iDelay == 'undefined') ? 750 : iDelay;
this.each( function ( i ) {
$.fn.dataTableExt.iApiIndex = i;
var
$this = this,
oTimerId = null,
sPreviousSearch = null,
//anControl = $( 'input', _that.fnSettings().aanFeatures.f );
anControl = $( 'table.dataTables input', _that.fnSettings().aanFeatures.f );
anControl.unbind( 'keyup' ).bind( 'keyup', function() {
var $$this = $this;
if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
window.clearTimeout(oTimerId);
sPreviousSearch = anControl.val();
oTimerId = window.setTimeout(function() {
$.fn.dataTableExt.iApiIndex = i;
//if (anControl.val() != '-1')
_that.fnFilter( anControl.val() );
}, iDelay);
}
});
return this;
} );
return this;
};
[/code]