1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-18 11:52:11 +01:00

Fixed: fnInitComplete was not the last thing to be executed when using DOM source. IT was possible that you could set sAjaxSource in fnInitComplete which would then trigger DataTables to do an Ajax call incorrectly.

This commit is contained in:
Allan Jardine 2010-12-15 21:23:24 +00:00
parent ede9f77de8
commit 525fad090e

View File

@ -26,7 +26,7 @@
* building the dynamic multi-column sort functions.
*/
/*jslint evil: true, undef: true, browser: true */
/*globals $, jQuery,_fnExternApiFunc,_fnInitalise,_fnLanguageProcess,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnGatherData,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnArrayCmp,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap*/
/*globals $, jQuery,_fnExternApiFunc,_fnInitalise,_fnInitComplete,_fnLanguageProcess,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnGatherData,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnArrayCmp,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap*/
(function($, window, document) {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@ -2325,8 +2325,9 @@
}
}
/* If there is default sorting required - let's do it. The sort function
* will do the drawing for us. Otherwise we draw the table
/* If there is default sorting required - let's do it. The sort function will do the
* drawing for us. Otherwise we draw the table regardless of the Ajax source - this allows
* the table to look initialised for Ajax sourcing data (show 'loading' message possibly)
*/
if ( oSettings.oFeatures.bSort )
{
@ -2339,7 +2340,7 @@
_fnDraw( oSettings );
}
/* if there is an ajax source */
/* if there is an ajax source load the data */
if ( oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide )
{
oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, [], function(json) {
@ -2366,19 +2367,38 @@
}
_fnProcessingDisplay( oSettings, false );
/* Run the init callback if there is one - done here for ajax source for json obj */
if ( typeof oSettings.fnInitComplete == 'function' )
{
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings, json );
}
_fnInitComplete( oSettings, json );
} );
return;
}
/* Server-side processing initialisation complete is done at the end of _fnDraw */
if ( !oSettings.oFeatures.bServerSide )
{
_fnProcessingDisplay( oSettings, false );
_fnInitComplete( oSettings );
}
}
/*
* Function: _fnInitalise
* Purpose: Draw the table for the first time, adding all required features
* Returns: -
* Inputs: object:oSettings - dataTables settings object
*/
function _fnInitComplete ( oSettings, json )
{
oSettings._bInitComplete = true;
if ( typeof oSettings.fnInitComplete == 'function' )
{
if ( typeof json != 'undefined' )
{
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings, json );
}
else
{
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings );
}
}
}
@ -3174,16 +3194,13 @@
oSettings.bSorted = false;
oSettings.bFiltered = false;
oSettings.bDrawing = false;
/* On first draw, initilaisation is now complete */
if ( typeof oSettings._bInitComplete == "undefined" )
if ( oSettings.oFeatures.bServerSide )
{
oSettings._bInitComplete = true;
if ( typeof oSettings.fnInitComplete == 'function' &&
(oSettings.oFeatures.bServerSide || oSettings.sAjaxSource === null) )
_fnProcessingDisplay( oSettings, false );
if ( typeof oSettings._bInitComplete == 'undefined' )
{
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings );
_fnInitComplete( oSettings );
}
}
}