问题
I like to bind the event onKeyDown after tinyMCE has already initiated for the site.
$('#content_ifr').keydown(...);
doesn't work here. So how could it be done?
回答1:
Firstly your jQuery selector is invalid...it is looking for a tagName content_ifr
which certainly can't exist.
Assuming element has ID content_ifr
use:
$('#content_ifr').keydown(...);
To call this after TinyMCE initialized use the TinyMCS oninit
calback in your config object.
Reference docs: http://www.tinymce.com/wiki.php/Configuration:oninit
You can probably use jQuery event delegation to call your code any time without needing to call it in TinyMCE config using jQuery on()
or delegate()
methods
EDIT: If element is an Iframe which I suspect it is from the selector, you would need to use contents()
method to bind keydown
event within the iframe
http://api.jquery.com/on/
http://api.jquery.com/delegate/
回答2:
$('#'+your_editor_id + '_ifr').bind('keydown',function(){
//do what you like here with the event
});
回答3:
You can write something like this:
$('content_ifr').bind('keydown',function(){
//your code goes here
});
来源:https://stackoverflow.com/questions/12880643/bind-onkeydown-after-tinymce-is-already-initiated