Building a forum and using Ckeditor for message posting - which works fine using textarea within a form. Now I want user to be able to edit their post so I have ckeditor working inline so user clicks on their post and their message is replaced by ckeditor. That works so far and looks good. But the save button is disabled. I surrounded the whole thing in a form, but of course ckeditor is now a div and not a text area so I guess form will not work. So how do I pass the data on to my PHP?
Another issue is that Ckeditor doesn't seem to work on mobile phone. Can you think of a good simple fallback method for mobiles?
This is the code I am using to render the inline editor;
// Uncomment the following code to test the "Timeout Loading Method".
// CKEDITOR.loadFullCoreTimeout = 5;
window.onload = function() {
// Listen to the double click event.
if (window.addEventListener)
document.body.addEventListener('click', onClick, false);
else if (window.attachEvent)
document.body.attachEvent('onclick', onClick);
};
function onClick(ev) {
// Get the element which fired the event. This is not necessarily the
// element to which the event has been attached.
var element = ev.target || ev.srcElement;
// Find out the div that holds this element.
var name;
do {
element = element.parentNode;
}
while (element && (name = element.nodeName.toLowerCase()) &&
(name != 'div' || element.className.indexOf('edit_post') == -1) && name != 'body');
if (name == 'div' && element.className.indexOf('edit_post') != -1)
replaceDiv(element);
}
var editor;
function replaceDiv(div) {
if (editor)
editor.destroy();
editor = CKEDITOR.replace(div, {
uiColor: '#FFFFFF',
toolbar: [
['Save', 'Cut', 'Copy', 'Paste', 'PasteFromWord', '-', 'Undo', 'Redo', '-', 'Scayt'],
'/',
['Bold', 'Italic', 'Underline', 'Blockquote', '-', 'Link', 'Unlink', '-', 'Image', 'Smiley', 'oembed']
]
});
}