[Bug] The custom block doesn't execute its script when autoloaded from localStorage
Question
I'm using the following code for my custom block, and it works when the block is dropped on the canvas.
But when the block is loaded from localStorage, it only creates a div wrapper and doesn't execute the content.script part of custom block.<br>
I tried simplifying the script property to just alert or console call but it didn't help. No errors in console.
blockManager.add('a3-owl-carousel', {
label: 'Owl Carousel',
content:{
type: 'slider',
script: function(){
var _component = this;
(function($){
$.get('http://localhost:8080/content/hr.json', function(data){
$.get('http://localhost:8080/content/slider.twig', function(twig_template){
var template = Twig.twig({data: twig_template});
$(_component).html(template.render(data));
});
});
})(jQuery);
}
}
}); `Answers (2)
False alarm, sorry. I checked the grapesjs-preset-webpage, and realized I was registering the block but no component. Once I added the component to editor.DomComponents, it started rendering the carousel even when loaded from localStorage.
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 #1895
[QUESTION] Drag component over canvas with script, script appended multiple times.
Hi, not sure if this is a bug or not. But I noticed a weird behavior, when I drag a block that has a component that contains a script funct...
Issue #459
Error when including a custom component inside another block
Sorry for the vague title. I'm not sure how to describe this concisely. I have a custom block where i want to restrict that only images can...
Issue #1565
Issue to create a "2 columns" block
Hi, Have a new problem, i'm following the tuto and i want to create the block "2 columns" (or more). I try to use (and understand, that's w...
Issue #2014
[BUG] - Not able to get content of a link block
Hello all, I am using grapesjs version 0.14.52. I am having the following issue: When I drop a link block inside the canvas, I can use the...
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.