GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.37k stars 4.05k forks source link

Edit Template into Database, need help with urlLoad #375

Closed kamleshkatpara closed 7 years ago

kamleshkatpara commented 7 years ago

@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 :

id template-name template-data
1 first {"gjs-assets":"[]","gjs-css":"*{box-sizing: border-box;}body{margin:0;}","gjs-styles":"[]","gjs-html":"\"components\":[]},
artf commented 7 years ago

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

lock[bot] commented 5 years ago

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.