Turn off Global AJAX Events?

Turn off Global AJAX Events?

dougtdougt Posts: 1Questions: 0Answers: 0
edited February 2014 in General
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]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Try DataTables 1.10.0-beta.2 perhaps? it has a new 'debounce' built in for the global input filter so there is a delay allowing further input from the user after each keystroke.

    In 1.9 - the fnSetFilteringDelay ( http://datatables.net/plug-ins/api#fnSetFilteringDelay ) plug=-in achieves basically the same thing.

    Allan
This discussion has been closed.