Hello.
I’m trying to add some javascript for a tinymce field. This works but only when the field loads in visual mode. If the field loads in text-mode, the init function that the API documents does not seem to trigger. So in that case, my javascript won’t run. Any ideas on what I must do to get this to trigger on the fields when the user changes from textmode to visual mode?
I’m using the following:
jQuery(document).ready(function () {
acf.add_action('wysiwyg_tinymce_init', function( ed, id, mceInit, field ){
ed.on('BeforeSetContent', function(e) {
if (e.content.startsWith("<table ")) {
e.content = '<div class="u-table-scrollable-X u-marginBottom-4">' + e.content + '</div>';
}
});
});
});