From a9f1ba1c0bbad50d9e16aa830f0b341f3a1b4888 Mon Sep 17 00:00:00 2001 From: Joost Molenkamp Date: Sun, 11 Sep 2022 21:15:23 +0200 Subject: [PATCH] PageResize: delay initial call to _size until table is fully initialized --- features/pageResize/dataTables.pageResize.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/features/pageResize/dataTables.pageResize.js b/features/pageResize/dataTables.pageResize.js index 522733c..161ce06 100644 --- a/features/pageResize/dataTables.pageResize.js +++ b/features/pageResize/dataTables.pageResize.js @@ -98,7 +98,15 @@ var PageResize = function ( dt, pageResizeManualDelta ) dt.on('destroy.pageResize', onDestroy); this._attach(); - this._size(); + + // Delay the initial sizing until the table is fully initialized + // such that the pagination element is also added and can be taken + // into account. + var initEvent = 'init.pageResize'; + dt.on(initEvent, function () { + dt.off(initEvent); + this._size(); + }.bind(this)); };