Load from Database
Question
I've got an issue with loading the lory-slider from my mysql db. When i load it back in, the functionality is gone, i cant slide left or right.
here is my save code:
` var cmdm = editor.Commands;
cmdm.add('save-db', {
run: function (em, sender) {
sender.set('active', true);
//get full HTML structure after design
//var InnerHtml = this.frameEl.contentDocument.activeElement.innerHTML;
var InnerHtml = editor.getHtml();
var css = editor.getCss();
console.log(editor);
//set post to save all HTML structure after design to DB
$.post("savetoDB.asp", { html: InnerHtml, css: css }, function (result) {
console.log("Saved to db");
sender.set('active', false);
}).fail(function(fail){
console.log(fail.responseText);
sender.set('active', false);
}); }});
and load which is converted from string to JSON format, im using asp classic so thats why its looking a bit weird:
`response.write "{""gjs-css"":""" & css &""", ""gjs-html"":"""&""& html&""&"""}"`
What i can see is that the data-gjs-type is sat to default on load, where as a new slider have data-gjs-type = "lory-slider"Answers (3)
@artf Im stuck could you maybe help me out?
You don't need that custom command, use the built-in remote storage, just storing HTML is not enough https://grapesjs.com/docs/modules/Storage.html
Thanks i solved it.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #382
Store the html and inline css in Editor.Store()
I am trying to store the html and inline css , can you please in how to pass it to editor.store() function. @artf
Issue #814
[QUESTION] Disable selectable, hoverable and editable options when Mobile view is on.
Hi, I want to disable to select, hover or edit the components of the editor when the Mobile view is on. I have tried using below code. But...
Issue #1881
Commands with a stop method, never programmatically stoped don`t run again!
Problem When you add a custom command with stop and dont stop will not run again if I dont set force: 1 as a parameter when running. When y...
Issue #400
Hide An element in commands
Hi, I want to hide a particular element when ever we click a toolbar button commands: { defaults: [{ id: 'submenuitem', run: function(edito...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.