How to update content of an existing jodit editor in a function

1.4k Views Asked by At

i use jodit in my website and wonder, how the content of an existing jodit editor can be updated within a function.

first i do....

$( document ).ready(function() {
   var editor_adressblock = new Jodit('#adressblock', {
    fullsize: false
 });
});

and the editor is correctly created.

I have a function, which can be executed by the user and then should load content (via json-request) and then put the content into the existing jodit textarea. Here is my try (for this example i have simplified the function) :

function takeover_adressblock(kunde_id, kunden_adresse_id) {
   // get data by ajax.... not shown in this example
   var data_by_ajax="test";
   editor_adressblock.value=data_by_ajax; // this fails.... 
}

Means, i don't know how i can send data to the existing jodit texteditor...

I am a jquery beginner, so please don't be too hard ;-)

Best regards Daniel

1

There are 1 best solutions below

0
On

Per the documentation you seem to have the right format, so it would help to see the code for the ajax request you're making in case the issue is there.

Otherwise, I would suggest initializing the editor without jQuery in case it's a reference or scoping issue:

const editor = Jodit.make('#editor');
editor.value = '<p>start</p>';