Search code examples
epiceditor

EpicEditor: update database


I have 3 EpicEditors on my webpage, each containing text related to an attribute of an object in my database. When I update the text, I see that the localStorage gets updated. But what I want to do is to save the changes to my database.

From the documentation, there is an exportFile event:

syncWithServerBtn.onclick = function () {
  var theContent = editor.exportFile();
  saveToServerAjaxCall('/save', {data:theContent}, function () {
    console.log('Data was saved to the database.');
  });
}

How does this work? Is there really a syncWithServer button? All I see are the preview and fullscreen buttons.

I suppose it means I must have a '/save' route in my views. How can I access theContent (the updated content) in this view?


Solution

  • No, syncWithServer is just an example if you had a button that did that. In the example, when you click the made up button it grabs the editor contents and then sends it to the DB with a fake saveToServerAjaxCall method. EpicEditor does nothing special for the server. This example is just showing a simple process of getting it there.