Hi,
I'm having real problems at the moment!
I'm writing a small web-app in php, sql and using jquery.
Using the jquery plugin I'm able to display a div containing data (i.e. data is readonly) and on clicking an 'edit' button, I'm able to replace that div with an instance of ckeditor and edit the post. So far so good.
The problem is that no matter what I try, I can't get the ckeditor to post the data!
My error checking tells me that the ckeditor fields are posting blank data. I suspect that isn't the case as if I replace a textarea it works fine!
What seems to be happening (and I've seen this by running an 'alert') is that when ckeditor replaces the div, it doesn't pick up the 'name' attribute.
Can someone please advise my how to set the 'name' of the editor when it's instantiated? I've tried adding "name : 'myname'" into the config (alongside skin & other variables) but it's just not being picked up!
Thanks in advance for any assistance.
I'm having real problems at the moment!
I'm writing a small web-app in php, sql and using jquery.
Using the jquery plugin I'm able to display a div containing data (i.e. data is readonly) and on clicking an 'edit' button, I'm able to replace that div with an instance of ckeditor and edit the post. So far so good.
The problem is that no matter what I try, I can't get the ckeditor to post the data!
My error checking tells me that the ckeditor fields are posting blank data. I suspect that isn't the case as if I replace a textarea it works fine!
What seems to be happening (and I've seen this by running an 'alert') is that when ckeditor replaces the div, it doesn't pick up the 'name' attribute.
Can someone please advise my how to set the 'name' of the editor when it's instantiated? I've tried adding "name : 'myname'" into the config (alongside skin & other variables) but it's just not being picked up!
Thanks in advance for any assistance.
Re: Problem with setting field name
Re: Problem with setting field name
Sorry, I'm a js newb! Can you explain a little more what you mean please?
Re: Problem with setting field name
If you want to submit some content back to the server you might have to create a form and add the inputs that you want to submit. CKEditor doesn't create such inputs.
Re: Problem with setting field name
If you could just point me at a specific example to examine that might do this, I'd be very grateful!
Re: Problem with setting field name
I'm now using ckeditor to post html values into the db.
If I replace a textarea with ckeditor, it posts ok, because it picks up the name of the textarea and posts the values.
The problem is that textareas don't render the code, so I see lots of html tags. As such I'm displaying a div with the initial content when in 'read' mode, then via jquery I'm making all fields editable - in the case of ckeditor I'm creating an instance for editing.
Which function/tool/option should I be calling to make this work/post back to the text area? Can you point me at a specific piece of documentation/example that will help me learn, please?
Thanks
Re: Problem with setting field name
When you want to save the content, read the data of the instance and assign it to a hidden input.
Something like
Re: Problem with setting field name
I was re-reading last night and wondering if it was getData() I needed to use!
The html is pretty simple - just basic formatting stuff, so hopefully there won't be too many problems!
Thanks for your help!
Re: Problem with setting field name
Thanks for your help so far on this - I think I'm getting there - but I think I've hit another snag!
The problem is that I have multipl ckEditor instances running in this particular form.
The form consists of two fields, both of which contain 'copy' text (i.e. descriptive text that needs to be formatted for output). The first field is called 'keynote', the second is called 'description'.
When the page loads, it displays two divs showing the current, formatted data.
When I click 'edit', it runs the following script:
So far, so good - it works.
I'm planning on using the script you outline above and converting it to jquery - basically getting the value of the editor (using editor.getData()) and appending it to a hidden input value. One input called 'keynote', another called 'description'.
In theory, my code looks like this when 'save' is clicked (using an 'each' loop as above)
**I have a suspicion this line won't work as I've not fully checked out the syntax for getData() - feel free to point me in the right direction!
The problem is that the editor instance does not have a name!
Using the code I found here: http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#name
I've added some alerts to my initial 'edit' functionality so the code looks like this:
**This is the bit that's not working for me - as far as I can tell in the documentation, this code should work - but it's not.
Even without that line, just returning CKEDITOR.name gives me 'undefined', so to an extent, I'm back to my original question - how do I define the name of my ckEditor instances!
Thanks in advance for your help on this!
Re: Problem with setting field name
Re: Problem with setting field name
Re: Problem with setting field name
Re: Problem with setting field name
I've just had a thought that I'm going to try out - I may still need to come back to you on this!
Re: Problem with setting field name
This works for multiple divs with editors assigned to them. All you need to do is give all divs the same class (I used "content_block").
Re: Problem with setting field name
Thank you all so much for your help.
Here is the final working code. I hope it helps someone!
Re: Problem with setting field name
The original code caused issues when posting copy with an apostrophe or single quote mark - it truncated anything after that.
I've amended it (mainly by switching quotes around) to read thus:
It now works.