I have summernote editor applied to a textarea and I would like that when I type some text in the editor, that text should be reflected in a div, so I have a textarea and a div#result where the changes should be written on every keyup event :
<textarea class="description"></textarea>
<br>
<div id="result">Text should change here</div>
I am using the callback onKeyup :
$('.description').summernote({
callbacks: {
onKeyup: function(e) {
$("#result").html($('.description').val());
}
}
});
Here is the jsfiddle for the demo purpose:
https://jsfiddle.net/vLdhpx5t/1/
When I type some continuous text, the content doesn't change in the div or at least it doesn't change exactly to match the content of my summernote editor
It seems like Summernote needs time to do its work (updating the editors window)...
A 200ms timeout solved the strange issue.
$('.description').summernote({
callbacks: {
onKeyup: function(e) {
setTimeout(function(){
$("#result").html($('.description').val());
},200);
}
}
});
Updated Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With