Issue #351Opened September 29, 2017by cmcintosh0 reactions

Issues with Loading new template after editor has initialized.

Question

I have a use case where I would like to allow users to switch the template they are editing.

On the initial load, the code seems to work fine and loads the template as expected, but on the subsequent loads the canvas is wiped blank.

load: function(keys, clb) {
        var result = {},
        fd = {},
        params = {
          'entity_type': drupalSettings.wembassy.siteBuilder.entity_type,
          'bundle': drupalSettings.wembassy.siteBuilder.bundle,
          'template': $('#gjs-pn-templates-a select').val(),
          'default': 1,
          'status': 1
        };

        for(var key in params)
          fd[key] = params[key];

        fd.keys = keys;

        let req = $.ajax({
          url: '/js/grapesjs/load',
          data: fd,
          async: false,
          method: 'GET',
        }).done(function(d) {
          var result = {};
          for (var i = 0, len = keys.length; i < len; i++){
            var v = d.data[keys[i]];
            if(v) result[keys[i]] = v;
          }
          console.log(result);
          clb(result);
          return result;
        });
      },

Answers (0)

No answers yet.

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.