Turn off Global AJAX Events?
Turn off Global AJAX Events?
Does anyone know how to disable global ajax events?
Currently my site uses ajaxStart and ajaxSop to universal display loading icons for all ajax events. This technique actually works fairly well with dataTables, except for one component, Global Search. Every letter typed in the search bar creates a new ajax call, which subsequently displays the loading animation. This seems like the desired effect, however, the pace at which the user types is causing unwanted UI issues (loading animations flickering and sometimes even crashing the site). Therefore, I was wondering if there is a way to disable global ajax events from happening when the global search function is used. Normally, I would add "global:false" to my ajax script, but I can't see to figure it out with dataTables - any help would be appreciated.
My Basic installation of dataTables:
[code]
$('.dynamicTable.colVis').dataTable({
"sPaginationType": "bootstrap",
"sDom": "<'row-fluid'<'span3'f><'span3'l><'span6'C>r>t<'row-fluid'<'span6'i><'span6'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ per page"
},
'bProcessing': true,
'bServerSide': true,
'sAjaxSource': '/ajax/clients/list_clients'
});
[/code]
Global ajax events:
[code]
$(document).ajaxStart( function()
{
$('#ajax_loading_modal').modal('show');
}).ajaxComplete( function(data, xhr, settings)
{
$('#ajax_loading_modal').modal('hide');
}).ajaxError(function(data)
{
$('#ajax_loading_modal').modal('hide');
});
[/code]
Currently my site uses ajaxStart and ajaxSop to universal display loading icons for all ajax events. This technique actually works fairly well with dataTables, except for one component, Global Search. Every letter typed in the search bar creates a new ajax call, which subsequently displays the loading animation. This seems like the desired effect, however, the pace at which the user types is causing unwanted UI issues (loading animations flickering and sometimes even crashing the site). Therefore, I was wondering if there is a way to disable global ajax events from happening when the global search function is used. Normally, I would add "global:false" to my ajax script, but I can't see to figure it out with dataTables - any help would be appreciated.
My Basic installation of dataTables:
[code]
$('.dynamicTable.colVis').dataTable({
"sPaginationType": "bootstrap",
"sDom": "<'row-fluid'<'span3'f><'span3'l><'span6'C>r>t<'row-fluid'<'span6'i><'span6'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ per page"
},
'bProcessing': true,
'bServerSide': true,
'sAjaxSource': '/ajax/clients/list_clients'
});
[/code]
Global ajax events:
[code]
$(document).ajaxStart( function()
{
$('#ajax_loading_modal').modal('show');
}).ajaxComplete( function(data, xhr, settings)
{
$('#ajax_loading_modal').modal('hide');
}).ajaxError(function(data)
{
$('#ajax_loading_modal').modal('hide');
});
[/code]
This discussion has been closed.
Replies
In 1.9 - the fnSetFilteringDelay ( http://datatables.net/plug-ins/api#fnSetFilteringDelay ) plug=-in achieves basically the same thing.
Allan