0
構建論壇並使用Ckeditor發送消息 - 在表單內使用textarea可以正常工作。現在我希望用戶能夠編輯他們的帖子,因此我讓ckeditor以內聯方式工作,以便用戶點擊他們的帖子,他們的消息被ckeditor取代。這工作到目前爲止,看起來不錯。但保存按鈕被禁用。我用表單包圍了整個事物,但當然ckeditor現在是div而不是文本區域,所以我猜表單不起作用。那麼如何將數據傳遞給我的PHP呢?ckeditor內聯保存
另一個問題是,Ckeditor似乎沒有在手機上工作。你能爲移動設備考慮一個簡單的回退方法嗎?
這是我用來渲染內聯編輯器的代碼;
// 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']
]
});
}