grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Load from Database

Open Skovmissen opened this issue 8 years ago • 6 comments

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"

Skovmissen avatar Oct 08 '18 13:10 Skovmissen

@artf Im stuck could you maybe help me out?

Skovmissen avatar Oct 09 '18 07:10 Skovmissen

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

artf avatar Oct 10 '18 22:10 artf

Thanks i solved it.

Skovmissen avatar Oct 12 '18 06:10 Skovmissen

@Skovmissen How did you solve this problem, by using remote storage or by another way?

ahmedeldeeb25-zz avatar Apr 14 '19 20:04 ahmedeldeeb25-zz

@ahmedeIdeeb25 Yes i ended up using the remote storage, i cant link my code because i dont have access to the project anymore due to new job.

Skovmissen avatar Apr 14 '19 20:04 Skovmissen

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.

lock[bot] avatar Apr 15 '20 07:04 lock[bot]