Welcome Guest, Not a member yet? Register   Sign In
CKEditor only submit current content on second click!?
#1

[eluser]Sven Delle[/eluser]
I load range of records from a database via AJAX into a div.

From that div I click a record and load those details into the div (basically replacing the content of the div).

Now, I can edit the title - which is a standard text input.

But I have a textarea of in CKEditor instance. And I can't manage to get the current content saved to the db. I have to click the submit button TWICE, and only THEN does it update.

Now, I suspect it has to do with loading views into divs through AJAX.

I receive the output from the server back through AJAX, and it show the original content of the textarea and not the edited version.

How do I manage to get the CURRENT edited version of the CKEditor instance posted to the server. I'm baffled, that this is an issue at all, but hey we're only counting 2012 in the web business, grrr!

Note: when I open FireBug, and edit the content of the textarea, I see no change in the DOM. Would I have to somehow call an update function (which sounds totally lame)? I've tried the updateElement(), but that makes no difference. So I guess not.

Anyone had similar issues with CKEditor?
#2

[eluser]Sven Delle[/eluser]
OK, why do I have to spend 8 hours hunting for a solution, and the minute(s) after posting to the forum, the solution suddenly pops up. Some scientist please explain THAT to me.

THE SOLUTION to my problem was that I had to call this before posting to the server:

Code:
for ( instance in CKEDITOR.instances )
{
CKEDITOR.instances[instance].updateElement();
}

Now, WHY on earth isn't that called automatically so that one shouldn't spend hours fixing it. I'm baffled ...
#3

[eluser]Stefan Hueg[/eluser]
[quote author="Sven Delle" date="1335631538"]
Now, WHY on earth isn't that called automatically so that one shouldn't spend hours fixing it. I'm baffled ...[/quote]

I'm glad for you that you figured it out. The explanation is that constantly updating the underlaying textarea would be very inefficient. CKEDITOR is not the only WYSIWYG editor with this flaw.
#4

[eluser]Sven Delle[/eluser]
Yeah, but using a WYSIWYG editor in the first place would surely mean that you we're to POST something (usually to a server). There wouldn't be any point in WYSIWYG edititing anything if it wasn't meant to be saved somewhere.

And if I have to MANUALLY ADD that before I submit a form containing a CKEditor instance, then THAT should be ON THE FRONTPAGE OF THEIR WEBSITE - RIGHT BELOW THE TAGLINE. Or at least on the first page of the manual.

Now, why was this so hard to find - if it's that necessary to make the thing work?

There are a lot of guys out there doing great stuff, but VERY few of them actually manage to communicate its actual use to people expecting to use it, but haven't been part of making it.

One good example of how to DO IT PROPERLY is CodeIgniter (with some room for improvement - but hey, isn't there always?)!
#5

[eluser]Stefan Hueg[/eluser]
Have you tried to submit the data via AJAX or is it just a simple <form> with a simple action?
#6

[eluser]Sven Delle[/eluser]
It's AJAX. But also fixed.

Edited above post to having THE SOLUTION in bold and red.
#7

[eluser]Stefan Hueg[/eluser]
[quote author="Sven Delle" date="1335687985"]It's AJAX. But also fixed.

Edited above post to having THE SOLUTION in bold and red.[/quote]

Yeah I know that it's fixed but the way how CKEDITOR is working is that it listens for a form being submitted, updates the textareas contents and continues the submitting procedure.

As you have not used a usual form submit, you can not blame CKEDITOR Smile
#8

[eluser]Sven Delle[/eluser]
OK.

But in these days of so called web 2.0 interfaces (as I interpret it - javascript frontends), you'd expect to being able to find a solution for my scenario quicker.

But hey, I've wasted 8 hours before on even simpler stuff : ):

Like .\SQLEXPRESSS vs .\\SQLEXPRESS

Double backslash - spent a whole two days finding a solution for that 'scenario'.
#9

[eluser]Stefan Hueg[/eluser]
I know exactly what you are talking about. It's called work-blindness. One hint: If you encounter such an error and can not find it in reasonable time, do something else. Or stop working completely. Make a break.

With a fresh mind you will solve 99% of the problems, try to think in multiple directions Smile
#10

[eluser]Sven Delle[/eluser]
I absolutely aggree on that one. Problem is to stop the brain from spinning. If I hadn't hurt my knee I'd go for at run. That usually works.




Theme © iAndrew 2016 - Forum software by © MyBB