【发布时间】:2015-09-28 20:57:08
【问题描述】:
我们有一些代码用于验证在模糊上运行的 CKEditor textarea 上的输入。我们将ckeditor_textarea 类添加到所有使用CKEditor 的文本区域并运行此代码以将必要的函数附加到模糊事件:
$("textarea.ckeditor_textarea").each(function(){
var textarea_id = $(this).attr("id");
CKEDITOR.instances[textarea_id].on('blur',function(){
// Validation functions here
});
});
这可以在模糊事件发生时触发验证函数。但是我们还需要在提交前手动触发提交按钮时的模糊事件,以便在提交前对这些CKEditor文本区域运行验证功能。
如何触发 CKEditor textarea 上的模糊事件?使用 jQuery 语法(这当然不起作用,因为 CKEditor 实例不是 jQuery 对象),我基本上是在寻找这样的东西:
$("textarea.ckeditor_textarea").each(function(){
var textarea_id = $(this).attr("id");
CKEDITOR.instances[textarea_id].trigger('blur');
});
【问题讨论】:
标签: javascript jquery ckeditor