Reputation: 10089
I'm trying to update the content of my ckeditor but it didn't works
<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>
but I always having 1 in my ckeditor and the alert return
1
(1 with p but it didn't appear)this is CKEditor 4.0
I ever read post about this on but it was an oldest version
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>
But it didn't works
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>
I have all the time
1
in my consoleand
<script type="text/javascript" >
setTimeout(function(){
$('#monday').val('test');
$('textarea.ckeditor').each(function () {
var $textarea = $(this);
console.log($('#monday').val())
});
},5000)
</script>
return test
Upvotes: 0
Views: 6733
Reputation: 184
this another option
$('textarea.ckeditor').each(function () {
var $textarea = $(this);
$textarea.val(CKEDITOR.instances[$textarea.attr('name')].getData());
});
Upvotes: 1
Reputation: 184
what happens if you remove this line
CKEDITOR.instances.monday.updateElement(); ?
Upvotes: 1