Issue #1528Opened October 18, 2018by nine-2-five0 reactions

[Bug] The custom block doesn't execute its script when autoloaded from localStorage

Question

Code SnippetTEXT
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)

nine-2-fiveOctober 18, 20180 reactions

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.

lock[bot]October 18, 20190 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.