[Question]: Initializing Canvas Scripts and Styles dynamically
Question
Hello Grapejs team,
Thanks for this wonderful project saved my time and so far I had great experience with integration and your community support.
I want to load Canvas Styles and Scripts after the page is loaded from DB (Rest API) canvas: { styles: ['https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css'], scripts: ['https://code.jquery.com/jquery-3.3.1.slim.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js'] }
Is it possible to load this dynamically like
editor.Canvas or something. Please help me with this.
Answers (2)
Hi @inventorbit for such a case you should manipulate directly the canvas document
const scriptEl = document.createElement('script');
scriptEl.src = '...';
editor.Canvas.getDocument().head.appendChild(scriptEl);
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.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1123
[QUESTION] Onload event inside template
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...
Issue #1329
Question: How to use same CSS for Multiple pages
Hello Grapejs Team, We've been working on Multi-page Website Builder. For each project there will be multiple html pages with single common...
Issue #444
How to load css link into the head tag?
Hello, First of all, thanks for contributing such an amazing js framework. I am very new to grapesjs. And github too. https://github.com/ar...
Issue #1059
[Question]: Load html content from a file dynamically
Hi, I need to load content from a html file from server onto editor after or while initializing editor. How this can be implemented? HTML w...
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.