forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlazyframe-move-weatherwidget-init-into-ctrl.diff
45 lines (40 loc) · 1.43 KB
/
lazyframe-move-weatherwidget-init-into-ctrl.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
diff --git a/assets/controllers/weather-widget_controller.js b/assets/controllers/weather-widget_controller.js
index 52bb06d..bca6359 100644
--- a/assets/controllers/weather-widget_controller.js
+++ b/assets/controllers/weather-widget_controller.js
@@ -2,7 +2,11 @@ import { Controller } from 'stimulus';
export default class extends Controller {
connect() {
- this.initializeScriptTag(document, 'script', 'weatherwidget-io-js');
+ if (typeof __weatherwidget_init === 'function') {
+ __weatherwidget_init();
+ } else {
+ this.initializeScriptTag(document, 'script', 'weatherwidget-io-js');
+ }
}
initializeScriptTag (d, s, id) {
diff --git a/assets/turbo/turbo-helper.js b/assets/turbo/turbo-helper.js
index 411fde6..bb04c1f 100644
--- a/assets/turbo/turbo-helper.js
+++ b/assets/turbo/turbo-helper.js
@@ -7,10 +7,6 @@ const TurboHelper = class {
this.closeSweetalert();
});
- document.addEventListener('turbo:render', () => {
- this.initializeWeatherWidget();
- });
-
this.initializeTransitions();
}
@@ -38,12 +34,6 @@ const TurboHelper = class {
}
}
- initializeWeatherWidget() {
- if (typeof __weatherwidget_init === 'function') {
- __weatherwidget_init();
- }
- }
-
isPreviewRendered() {
return document.documentElement.hasAttribute('data-turbo-preview');
}