I want to add markup to the the iframe's body tag. Following code can do it but only if iframe content object is inside of click event. Here's example:
$(document).ready( function() {
var tinymceFrame = $('#editor_ifr').contents().find('#tinymce');
$('body').on('click', 'button', function() {
$(tinymceFrame).append('<img class="widgetty" title="Widget" src="" />');
});
});
This won't work but if I move tinymceFrame line inside click event it will work.
Also after image is added to iframe's body tag how to trigger on click event on that image? I tried something like:
$(tinymceFrame).on('click', '.widgetty', function() {
alert('test');
});