From 3d8efd04c6c27b420d3614fe95c19cc3bc16002a Mon Sep 17 00:00:00 2001 From: RouxRC Date: Mon, 28 Aug 2017 02:38:41 +0200 Subject: [PATCH] Ensure browser updates display before processing This enables actual rendering of processingIndicator and beforeProcess actions before processing heavy data from DOM freezes the rendering. This is already working fine when using ajax queries since asynchronous actions happen then, but from heavy html tables loaded in DOM, the process is calculating from the start without ever rendering a frame. --- jquery.dynatable.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jquery.dynatable.js b/jquery.dynatable.js index 9285e1e..0492099 100644 --- a/jquery.dynatable.js +++ b/jquery.dynatable.js @@ -206,7 +206,7 @@ }; processAll = function(skipPushState) { - var data = {}; + var data = {}, self = this; this.$element.trigger('dynatable:beforeProcess', data); @@ -214,6 +214,13 @@ // TODO: Wrap this in a try/rescue block to hide the processing indicator and indicate something went wrong if error this.processingIndicator.show(); + setTimeout(function(){ + processNow.call(self, data, skipPushState); + }, 0); + } + + processNow = function(data, skipPushState) { + if (this.settings.features.sort && !$.isEmptyObject(this.settings.dataset.sorts)) { data[this.settings.params.sorts] = this.settings.dataset.sorts; } if (this.settings.features.paginate && this.settings.dataset.page) { var page = this.settings.dataset.page,