[QUESTION] Onload event inside template
Question
Hi! I have a problem with some templates. This template has some scripts running after the page is loaded. When this templates is loaded by GrapeJs, the scripts do not starting because browser not detect the ending of load.
It's possibile to load templete in a classic iframe (not injected)?
For example:
<iframe src="http://myexamplepages.com" frameborder="0" style="overflow:hidden;height:100%;width:100%" height="100%" width="100%"></iframe>
It is possible to use this solution or you can suggest other one.
Thanks.
Answers (3)
Have you tried with this?
const editor = grapesjs.init({
...
allowScripts: 1,
});
Sure, other scripts with "allowScripts" parameter work fine, but scripts inside "on load event" don't.
I inject the code in this way:
` var newComps = editor.DomComponents;
$.get('http://myexamplepages.com', function (e) {
newComps.setComponents(e);
});
window.editor.setComponents(newComps);
`
Thanks.@alfaalex81 can you provide a live demo of the issue?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1906
Components & Js - Load Template
Hey, I have a component which has a JS attached to it. Everything is created using the JS. When I drag and drop my block for the first time...
Issue #1288
Cannot read property 'body' of null - Angular
Hi, I have a list of email template (page 'templates') and there is a button that open the edit (page 'templates/edit/:templateId'. All wor...
Issue #1162
[Question]: Editable components in Handlebars rendered template
Hi, I've been using grapes for about a couple of days now. Thanks for the awesome work on this project. I've read through the API docs (hop...
Issue #1255
[QUESTION]: How to set editor html contents from custom component?
I'm having trouble getting a custom block+component to display its template HTML inside the grapes editor. Within the exported HTML, the ma...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.