Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tinyMCE blur event

Hello I want to do some stuff when user finished writing in the tinyMCE textarea and click somewhere outside (onBlur). So far I haver try:

$('#id_topic_text_parent').live('blur',function(){
    alert('asd')
//I saw #id_topic_text_parent in firebug, it is span containing the tiny mce
});

also

$('#id_topic_title').blur(*and*)live('blur...
tinyMCE.activeEditor.blur(*and*)live('blur...

But it wont work.
Can you assist me.

like image 877
T1000 Avatar asked Apr 08 '11 09:04

T1000


2 Answers

according to http://www.tinymce.com/wiki.php/api4:event.tinymce.Editor.blur

This works for me

setup : function(ed) {
    ed.on('blur', function(e) {
        alert('blur');
    });
},
like image 166
ptguy Avatar answered Sep 28 '22 03:09

ptguy


You can use this approach to solve your issue. When initializing tinymce set the setup paramter to the following (inside tinyMCE.init({...})

...
theme: "advanced",   // example param
plugins = 'code',    // example param
setup : function(ed) {
    ed.onInit.add(function(ed, evt) {

        var dom = ed.dom;
        var doc = ed.getDoc();

        tinymce.dom.Event.add(doc, 'blur', function(e) {
            // Do something when the editor window is blured.
            alert('blur!!!');
        });
    });
},
cleanup: true,      // example param
...
like image 39
Thariama Avatar answered Sep 28 '22 01:09

Thariama