我們有一些代碼用於在模糊運行的CKEditor textarea上驗證輸入。我們一類的ckeditor_textarea
添加到使用的CKEditor和運行該代碼添加必要的功能,模糊事件的所有文字區域:如何觸發CKEditor textareas上的模糊事件?
$("textarea.ckeditor_textarea").each(function(){
var textarea_id = $(this).attr("id");
CKEDITOR.instances[textarea_id].on('blur',function(){
// Validation functions here
});
});
這個工作消防驗證功能時,模糊事件發生。但在提交之前,按下提交按鈕以在CKEditor textareas上運行驗證功能時,我們還需要手動觸發blur事件。
如何在CKEditor textarea上觸發模糊事件?使用jQuery語法(這當然不行,因爲CKEditor的實例不是一個jQuery對象),我基本上在尋找這樣的事情:
$("textarea.ckeditor_textarea").each(function(){
var textarea_id = $(this).attr("id");
CKEDITOR.instances[textarea_id].trigger('blur');
});
增加投票,因爲這可能是在某些情況下的一個很好的解決方案,'updateElement()'是一個好點。雖然這並不是我想要的,但它足以讓我解決我的情況。 (已發佈答案) –