tinyMCE textarea焦点活动?

Awa*_*wan 6 javascript jquery textarea tinymce focusout

我正在研究现有项目.我必须检测tinyMCE focusout/blur事件以通过AJAX自动保存它.我发现以下现有的工作代码:

// reinit tinymce
$($("#chapterBill div:.module-container")[indexAfter]).find('textarea').each(function(i){
   editorId = $(this).attr('id');
   tinymce.EditorManager.execCommand('mceAddControl',true, editorId);
});
Run Code Online (Sandbox Code Playgroud)

有人能告诉我如何捕获tinyMCE textarea focusout/blur事件吗?

谢谢

Tha*_*ama 5

您不想捕获textarea焦点/模糊.Tinymce隐藏了前textarea并创建了一个可以输入/编辑内容的满足iframe.此内容会不时地写入以前隐藏的文本区域(基于事件).

为了在编辑器上捕获焦点/模糊,您需要在编辑器iframe上为此设置处理程序.

将此代码放入您的tinymce init中

setup : function(ed) {
    ed.onInit.add(function(ed, evt) {
        tinymce.dom.Event.add(ed.getDoc(), 'blur', function(e) {
            // Do something when the editor window is blured.
            alert('blur!!!');
        });
    });
},
Run Code Online (Sandbox Code Playgroud)