I've been facing an issue with updating the content in my CKEditor
<textarea id="monday" class="ckeditor" name="monday" >1</textarea>
<script type="text/javascript" >
setTimeout(function(){
$('#monday').val('test');
CKEDITOR.instances.monday.updateElement();
alert( $('#monday').val());
},1000)
</script>
Despite trying different methods, I still end up with '1' in my CKEditor and the alert displays
1
(which doesn't show up)This is using CKEditor 4.0
I came across a post discussing a similar issue but for an older version of CKEditor
Thanks
edit: 2nd test
<script type="text/javascript" >
setTimeout(function(){
$('#monday').val('test');
for ( instance in CKEDITOR.instances )
{
CKEDITOR.instances[instance].updateElement();
}
alert( $('#monday').val());
},5000)
</script>
However, this approach didn't yield the desired result
Edit 3rd test
<script type="text/javascript" >
setTimeout(function(){
$('#monday').val('test');
$('textarea.ckeditor').each(function () {
var $textarea = $(this);
$textarea.val(CKEDITOR.instances[$textarea.attr('name')].getData());
console.log(CKEDITOR.instances[$textarea.attr('name')].getData());
console.log($('#monday').val())
});
},5000)
</script>
The console consistently shows
1
every timeand
<script type="text/javascript" >
setTimeout(function(){
$('#monday').val('test');
$('textarea.ckeditor').each(function () {
var $textarea = $(this);
console.log($('#monday').val())
});
},5000)
</script>
displays 'test'