Support

Account

Home Forums Backend Issues (wp-admin) Add javascript to tinymce fields which starts in textmode

Unread

Add javascript to tinymce fields which starts in textmode

  • 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>';
    			}
    		});
    
        });
    });
    
Viewing 1 post (of 1 total)

The topic ‘Add javascript to tinymce fields which starts in textmode’ is closed to new replies.