bard
bard

Reputation: 3072

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?

Upvotes: 0

Views: 130

Answers (2)

Jignesh Gohel
Jignesh Gohel

Reputation: 6552

I have given a detailed answer at https://stackoverflow.com/a/35285968/936494. demonstrating how we can use a button on a form to submit the EpicEditor contents. The button click event code shown in the example can be used as reference to bind event on any desired button on the page and submit the contents. Hope it helps.

Upvotes: 0

Oscar Godson
Oscar Godson

Reputation: 32766

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.

Upvotes: 1

Related Questions