hi,
I am integrating ckeditor into a php framework (called 'qcubed') and am having some trouble with getting data out when I do an ajax post. Due to limitations in my framework, my ajax post will only post the contents of the original div, so I figure I need to update that element before I post.
I had seen elsewhere that the key is to use the updateElement() function, so I wrote something like this:
which gets called before I post.
This, however does not appear to work. I tried a few other variations, to make sure I was referencing the correct elements, etc:
In this example, I get the instance name 'c23', then I get the textarea contents, which is NOT updated, although I expect it should be, and then I get the modified data with 'getData()', which does reflect the correct changes.
I can probably just force the update by using getData and then jQuery to update the textarea manually, but that doesn't seem very clean and I'd like to know why updateElement doesn't seem to be working.
the other thing I think is strange is that I generate the code using the .editor() function as defined in ckeditor_php5.php. While that works, it gives me this (for the 'hidden' element):
Shouldn't that element have an 'id' attribute? Why just a 'name' attribute? Could that be the problem?
I am integrating ckeditor into a php framework (called 'qcubed') and am having some trouble with getting data out when I do an ajax post. Due to limitations in my framework, my ajax post will only post the contents of the original div, so I figure I need to update that element before I post.
I had seen elsewhere that the key is to use the updateElement() function, so I wrote something like this:
<script type="text/javascript"> function updateEditor() { for ( instance in CKEDITOR.instances ) { CKEDITOR.instances[instance].updateElement(); } } </script>
which gets called before I post.
This, however does not appear to work. I tried a few other variations, to make sure I was referencing the correct elements, etc:
<script type="text/javascript"> function updateEditor() { for ( instance in CKEDITOR.instances ) { CKEDITOR.instances[instance].updateElement(); alert('instance value: ' + instance); var str = $j('textarea[name="c23"]').html(); // the element name that gets relaced alert(str); var content = CKEDITOR.instances[instance].getData(); alert(content); } } </script>
In this example, I get the instance name 'c23', then I get the textarea contents, which is NOT updated, although I expect it should be, and then I get the modified data with 'getData()', which does reflect the correct changes.
I can probably just force the update by using getData and then jQuery to update the textarea manually, but that doesn't seem very clean and I'd like to know why updateElement doesn't seem to be working.
the other thing I think is strange is that I generate the code using the .editor() function as defined in ckeditor_php5.php. While that works, it gives me this (for the 'hidden' element):
<textarea name="c23" rows="8" cols="60" style="visibility: hidden; display: none; "> </textarea>
Shouldn't that element have an 'id' attribute? Why just a 'name' attribute? Could that be the problem?
Re: weird updateElement issues
And I discovered that it just never gets called. Here is where I'm trying to call it:
Re: weird updateElement issues
Anyone have this issue?