开发者

TinyMCE: Detecting onLeave()

开发者 https://www.devze.com 2022-12-14 15:53 出处:网络
I am trying to detect when the user has left the tinyMCE editor window but I am unable to do so. Here is the code that i think should work (but isnt):

I am trying to detect when the user has left the tinyMCE editor window but I am unable to do so. Here is the code that i think should work (but isnt):

$('.mceEditor').blur(function(){
    // I would expect this to f开发者_C百科ire when the user leaves the
    // tinyMCE editor, but it never seems to fire
});

I've also tried:

$('*')
    .not('.mceEditor, .mceEditor *')
    .click(function(){
        // I would expect this to fire when anything but the tinyMCE editor
        // has been clicked, but it seems to fire at every click
    });

Neither methods are working and ive been at this for hours. Any help would be greatly apreciated.

Thanks, Simon

PS: I am using the jquery plugin version, found here: http://tinymce.moxiecode.com/examples/example_23.php


I guess this should work

tinyMCE.dom.Event.add(tinyMCE.getInstanceById("editor-id").getWin(), "blur", function(){
    // Blur operations
});


Looks like tinymce is being plugged in with an iframe. In that case you would have to access the iframe's DOM, something like this might work.

$("#content_ifr").contents().find('#tinymce');

Where content_ifr is the ID of the iframe and #tinymce seems to be the tag that encloses the content. Use firebug and poke around to see.


TinyMCE creates editor as an iframe inside a wrapper SPAN element. you can use SPAN element 'onfocusout' event.

Ex: if textarea element id is 'content', TinyMCE creates a SPAN with element id 'content_parent'.

$("#content_parent")[0].onfocusout =function(){alert('mouse out');};
0

精彩评论

暂无评论...
验证码 换一张
取 消