Issue #347Opened September 28, 2017by cmcintosh0 reactions

Storing to Drupal

Question

This is inside of a Plugin, I can confirm after init. That the editor is using the defined storage that I defined. Additionally, I can trigger editor.load() and editor.store() and see ajax calls go out if i crate them in the respective options. However, if I do not have load or store defined then I see no traffic in the network console.

` var storageManager = editor.StorageManager; var drupalStorage = storageManager.add('drupal', { type: 'remote', urlStore: '/js/grapesjs/save',

Code SnippetTEXT
urlLoad: '/js/grapesjs/load',
      autosave: true,
      params: {
        entity_type: drupalSettings.wembassy.siteBuilder.entity_type,
        'bundle': drupalSettings.wembassy.siteBuilder.bundle,
        'template': $('#gjs-pn-templates-a select').val(),
        'default': 1,
        'status': 1
      },
      load: function(keys) {
        console.log('Loading', keys);
        var res = {};
        for (var i = 0, len = keys.length; i < len; i++){
          var v = drupalSettings.wembassy.siteBuilder.template_data[keys[i]];
          if(v) res[keys[i]] = v;
        }
        return res;
      },
      store: function(data){
        var templateData = {
          'entity_type': drupalSettings.wembassy.siteBuilder.entity_type,
          'bundle': drupalSettings.wembassy.siteBuilder.bundle,
          'template': $('#gjs-pn-templates-a select').val(),
          'data': data,
          'default': 1,
          'status': 1,
        };
        $.ajax({
          type: "POST",
          url: "/js/grapesjs/save",
          data: templateData,
          async: false,
          success: function(e) {
            console.log("Saved data", e);
            return true;
          },
          dataType: "json"
        });
      }});

    storageManager.setCurrent('drupal');
`

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.