3

I am using EpicEditor in one my project. So as per the doc, I have added textarea property to my textarea id, so when page load first time all content from textarea is showing in the EpicEditor. Works great!!!

PROBLEM:


I am getting real-time updates from server for that particular record and then I am updating the form fields value accordingly. So I am not able to set the new value in the EpicEditor. I have updated the reference textarea value but it will not sync to EpicEditor.

SOLUTION


I want to set the new value in the EpicEditor whenever some updates occurred on the reference textarea.

Deepak Biswal
  • 4,280
  • 2
  • 20
  • 37

2 Answers2

4
var self = this;
var opts = {
    container: 'epiceditor',
    textarea: 'myTextArea',
    basePath: 'epiceditor',
...
}
var editor = new EpicEditor(opts);
self.editor.load();
// Now, import some content into the editor
// Since I don't know the filename I'm using `null` which will default to the current filename 
editor.importFile(null, 'This is to be displayed in the epic editor');

This should automatically update the textarea. If it does not update the textarea that's a bug and please send a ticket with your code and a reproducible case:https://github.com/OscarGodson/EpicEditor/issues/new

Oscar Godson
  • 31,662
  • 41
  • 121
  • 201
  • I have done it `$("#myTextArea").val('This is to be displayed in the epic editor');me.editor._setupTextareaSync();`. Is that correct? It's working perfectly. – Deepak Biswal Aug 15 '13 at 07:04
  • See my comment above in your selected answer. – Oscar Godson Aug 15 '13 at 08:05
  • Yes, it's working but after calling `importFile` method I have to trigger preview or edit call to reflect the value in textarea. Is there a way to show latest content on textarea after calling `importFile`. – Deepak Biswal Sep 03 '14 at 09:31
  • Just for anyone else reading this, @deepakb 's issue seems to have been fixed since then. Calling `importFile` as shown above updates the editor. – Phillip Elm Aug 11 '16 at 20:49
-1

You can do something like this:

after you create an instance of epic editor with your options (opt) and load it. Put the text that you want to place in the epic editor as textarea value like this - $("#myTextArea").val('your value')) and call me.editor._setupTextareaSync();

var me = this;
var opts = {
    container: 'epiceditor',
    textarea: 'myTextArea',
    basePath: 'epiceditor',
    -------
    -------
}
var editor = new EpicEditor(opts);
me.editor.load();
$("#myTextArea").val('This is to be displayed in the epic editor');
me.editor._setupTextareaSync();

Cheers!

Manish Kumar
  • 15,269
  • 5
  • 18
  • 27
  • 1
    You should `importFile('filename', 'text in to go in editor')`. The textarea should update automatically when you do that. (If it does not, thats a bug and send us a bug report) Do _not_ use `_setupTextareaSync()`. As indicated with the underscore, this is a private, undocumented, unsupported and ephemeral method. – Oscar Godson Aug 14 '13 at 20:54