Reputation: 49
I'm trying to get contents of Jodit editor into a variable.
I have tried looking through their documentation but nowhere can I find how to do it. I've had a look at their methods documentation but information provided there doesn't connect any dots.
<textarea id="editor"></textarea>
<br>
<button class="btn btn-primary ml-3" id="save">Save</button>
<script>
var editor = new Jodit('#editor', {
});
$('#save').on('click', function(e) {
var text = editor.someMethodThatGetsContents();
alert(text);
});
</script>
I think I should get a html string.
Upvotes: 4
Views: 5846
Reputation: 171
from the docs:
function handleContent(newValue) {
...
const x = newValue.srcElement.innerHTML;
...
}
<JoditEditor
...
onBlur={handleContent}
...
/>
Upvotes: 1
Reputation: 57
var editor = new Jodit('#editor');
var editor_val = editor.value;
console.log(editor_val);
Try this way, maybe this going to help you.
Upvotes: 5