[QUESTIONS] Custom Code block and JS
Question
Wondering if there is a limitation or is it actually possible to create a block that allows the user of the editor to write custom javascript code as they are building the template? For example drag and drop a custom code block and write the javascript in it?
Example: I created a link and wanted to capture the click event to make an Ajax request etc... I know it is possible to update the editors initialization code to include an external javascript file but ideally we would like this to be handled dynamically in a single place without having to edit settings every time we add a new javascript function.
Answers (3)
Try
grapesjs.init({ allowScripts: 1, ... });
That just means you won't see the code, but you get something to see and click on to edit it. The JavaScript itself is there and works just fine.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1227
Re-render view in editor's canvas whenever Trait value changes
Is there any possible way in grapesjs that whenever a user changes the value of a Trait of a custom component the render function should li...
Issue #1960
[QUESTION] Dynamic class generation with a template
Hi there ! I am wondering if there is a way to force the dynamic class generation (of the form cXXXXX which happens when I drag'n'drop a co...
Issue #1683
How to change id/class when new element drop on editor or render element with dynamic ip?
Hello @artf , Hope you are doing well. I have two questions regards dynamic blocks adding, 1) Is it possible to render the block with dynam...
Issue #1661
I've created html table and cannot drag new elements to table cells
Hello. if I create html table with next block of code, everything works, I'm able to drop a Quote, for example, to any cell: But next code...
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.