Issue #375Opened October 4, 2017by mekamleshk0 reactions

Edit Template into Database, need help with urlLoad

Question

@arthuralmeidap @artf @cmcintosh

I am trying to edit a existing template in the database,

I am unable to send the template data and id to the view

var id = '<?php echo $this->uri->segment(4); ?>';

       var editor = grapesjs.init
           ({
             height: '100%',
              container : '#gjs',
              plugins: ['gjs-preset-newsletter'],
          storageManager:
          {
            type: 'remote',
            autosave: false,
            //urlStore: 'dragdrop/edit/id',
            urlLoad: 'dragdrop/edit/id',
            contentTypeJson: true,
          },
        });

      editor.Panels.addButton
          ('options',
            [{
              id: 'save-db',
              className: 'fa fa-floppy-o',
              command: 'save-db',
              attributes: {title: 'Draft'}
            }]
          );

        // Add the command
      editor.Commands.add
        ('save-db',
        {
          run: function(editor, sender)
          {
            sender && sender.set('active'); // turn off the button
            editor.store();
            alert('Draft');

            //   editor.on('storage:load', function(e) {
            //       console.log('Loaded ', e);
            // });

            // editor.on('storage:store', function(e) {
            //       console.log('Stored ', e);
            // });         
          }
      });

I have this structure in my db :

<table style="width:100%"> <tr> <th>id</th> <th>template-name</th> <th>template-data</th> </tr> <tr> <td>1</td> <td>first</td> <td>{"gjs-assets":"[]","gjs-css":"*{box-sizing: border-box;}body{margin:0;}","gjs-styles":"[]","gjs-html":"\"components\":[]},</td> </tr> </table>

Answers (2)

artfOctober 4, 20170 reactions

@mekamleshk we're already talking about this here #368 there is no need to create another issue with the same content, thanks

lock[bot]September 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.