I'm writing a plugin for TinyMCE and have a problem with detecting click events inside an iframe.
From my search I've come up with this:
Loading iframe:
<iframe src='resource/file.php?mode=tinymce' id='filecontainer'></iframe>
HTML inside iframe:
<input type=button id=choose_pics value='Choose'>
jQuery:
//Detect click
$("#filecontainer").contents().find("#choose_pic").click(function(){
//do something
});
Other posts I've seen usually have a problem with different domains (this hasn't). But, still, the event isn't detected.
Can something like this be done?
The tinymce API takes care of many events in the editors iframe. I strongly suggest to use them. Here is an example for the click handler
In my case, I was trying to fire a custom event from the parent document, and receive it in the child iframe, so I had to do the following:
and in the iframe document: