From 9323ccdd67efa1b823aaeb5a917aea43a4d87198 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Wed, 11 Dec 2013 10:57:42 +0000 Subject: [PATCH] fnReloadAjax: Update to be comaptible with 1.10. - Although 1.10 has its own Ajax reloading options built in, it makes sense to have fnReloadAjax work with 1.10 for old installations, so you can simply replace the plug-in rather than reworking all exisiting code! --- api/fnReloadAjax.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/fnReloadAjax.js b/api/fnReloadAjax.js index 1b5824c..98e5ef5 100644 --- a/api/fnReloadAjax.js +++ b/api/fnReloadAjax.js @@ -17,6 +17,21 @@ $.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw ) { + // DataTables 1.10 compatibility - if 1.10 then `versionCheck` exists. + // 1.10's API has ajax reloading built in, so we use those abilities + // directly. + if ( $.fn.dataTable.versionCheck ) { + var api = new $.fn.dataTable.Api( oSettings ); + + if ( sNewSource ) { + api.ajax.url( sNewSource ).load( fnCallback, !bStandingRedraw ); + } + else { + api.ajax.reload( fnCallback, !bStandingRedraw ); + } + return; + } + if ( sNewSource !== undefined && sNewSource !== null ) { oSettings.sAjaxSource = sNewSource; }