File size: 1,094 Bytes
62cfde8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
diff --git a/decidim-templates/app/packs/src/decidim/templates/admin/choose_template.js b/decidim-templates/app/packs/src/decidim/templates/admin/choose_template.js
index a363914c45..45299162b8 100644
--- a/decidim-templates/app/packs/src/decidim/templates/admin/choose_template.js
+++ b/decidim-templates/app/packs/src/decidim/templates/admin/choose_template.js
@@ -13,16 +13,10 @@ $(() => {
       return;
     }
     const params = new URLSearchParams({ id: id });
-    fetch(`${previewURL}?${params.toString()}`, {
-      method: "GET",
-      headers: { "Content-Type": "application/json" }
-    }).then((response) => response.text()).then((data) => {
-      const script = document.createElement("script");
-      script.type = "text/javascript";
-      script.innerHTML = data;
-      document.getElementsByTagName("head")[0].appendChild(script);
-    }).catch((error) => {
-      console.error(error); // eslint-disable-line no-console
+    Rails.ajax({
+      url: `${previewURL}?${params.toString()}`,
+      type: "GET",
+      error: (data) => (console.error(data))
     });
   }