Skip to content

Commit 6c33b99

Browse files
fix: prevent infinite chart reloading on elementor
1 parent 00d657e commit 6c33b99

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

js/render-facade.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
var vizClipboard1=null;
55
(function($, visualizer){
66

7+
// Once the facade is loaded, we need to refresh the charts. But we need to it one time only per chart.
8+
var chartReloadedAfterFacade = [];
9+
710
function initActionsButtons(v) {
811
if($('a.visualizer-chart-shortcode').length > 0 && vizClipboard1 === null) {
912
vizClipboard1 = new ClipboardJS('a.visualizer-chart-shortcode'); // jshint ignore:line
@@ -144,8 +147,13 @@ var vizClipboard1=null;
144147
if ( $(element).is(':visible') ) {
145148
var id = $(element).addClass('viz-facade-loaded').attr('id');
146149
showChart(id);
150+
151+
// Reload the chart and mark it as reloaded.
152+
if ( chartReloadedAfterFacade.indexOf( id ) === -1 ) {
153+
refreshEachCharts();
154+
chartReloadedAfterFacade.push( id );
155+
}
147156
}
148-
refreshEachCharts();
149157
});
150158

151159
// interate through all charts that are to be lazy-loaded and observe each one.

0 commit comments

Comments
 (0)