Search code examples
javascriptreal-timesynchronizationepiceditor

Sync value from textarea in EpicEditor after page loaded


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.


Solution

  • 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!