[英]jQuery ajaxForm and CKEditor not saving as it should
您好,對不起,這是一個非常大的系統的一部分,如果我遺漏了某些東西,我不會全部說明,請問我,
我正在使用jQuerys ajaxForm http://jquery.malsup.com/form/和CKEditor http://ckeditor.com
根據CKeditor上的文檔,jQuery適配器可與“與編輯器實例進行代碼交互”部分底部的ajaxForm http://ckeditor.com/blog/CKEditor_for_jQuery一起使用,
現在,我所有的內容都使用AJAX加載到頁面中,並且調用了名為addonLoader的函數,並將傳入的數據觸發到該頁面中,這是該函數處理CKEditor的部分
// check there are not any instance's of CKEditor running
$(".addonContent form textarea.editor").each(function(index, element) {
$(this).ckeditor(function(){ this.destroy(); });
});
// add the content to the output area
$(".addonContent").html(data);
// setup Ajax form values
AJAXFormOptions = {
success: addonLoader
};
// activate ajaxForm on any forms from the data shown
$(".addonContent form").ajaxForm(AJAXFormOptions);
// enable the content editor
$(".addonContent form textarea.editor").ckeditor({width:"800px"});
當我的表單由圖像鏈接提交以觸發此代碼時
function submitForm(formID){
(function($){
$(".addonContent form textarea.editor").each(function(index, element) {
$(this).ckeditor(function(e){
this.updateElement();
});
});
$(formID).submit(function(){
// prevent the browser redirect
return false;
});
$(formID).submit();
})(jQuery)
}
我已經檢查過formID是正確的,但是由於某種原因,它仍然無法使用CKEditor內的內容更新textarea,任何人都有這個問題,並且知道如何解決嗎?
在this
使用的是調用updateElement()
是一個DOM節點不是CKEditor的對象。
在您提供的適配器鏈接上,它顯示了如何從docs獲取訪問編輯器實例的方法,如下所示:
var editor = $('.jquery_ckeditor').ckeditorGet();
嘗試將this.updateElement()
更改為:
$(this).ckeditorGet().updateElement()
現在您應該在編輯器實例上調用更新
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.