GrapeJS can't load javascript
Hi. I have some script tag in my html code (includes js file and internal javascript tag) But GrapeJS doesn't load any script and apply this.
Can I have any way load javascript to grapejs and export html include javascript code?
Hi
You can allow script when you init grapesJS instance.
const editor = grapesjs.init({ ... allowScripts: 1, });
Hope that helps you.
@vishal5033 : many thanks for your helps. it works for me.
The script file and internal js will show when export html.
But I see the error message:
and

can you help me?
@phucphanJaneto try to post your code? maybe something is missing or you got the wrong syntax.
Yes.
var newComps = editor.DomComponents;
window.newCom = newComps;
$.get(response.HtmlLink, function (e) {
newComps.setComponents(e);
})
})
window.editor.setComponents(newComps);
You can test with attach html. b0c0c79f-41e5-437d-aa12-4aa3bfb198df.zip
@phucphanJaneto you're doing something wrong here
$.get(response.HtmlLink, function (e) {
// check the `e`, shoud be an HTML string or Component Object
newComps.setComponents(e);
})
})
Yes. this is a HTML string. i load html file which sent to you.
Hey, @artf
Can you see my comment above?
Check better the response (it might be a case to escape the string) and if headers are correct
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.