Home › Forums › ACF PRO › insert values into fields programmatically › Reply To: insert values into fields programmatically
Adding actions to tinyMCE editors.
I kept digging and I figured out how to add actions to the editors. This needs to be done only after the editor is added with the new “delay initialization” feature of wysiwyg fields.
jQuery(document).ready(function($){
tinyMCE.on('addEditor', function(e) {
// fires every time an editor is initialized
if (typeof(e.editor) == 'undefined' || !e.editor.id.match(/^acf-editor-/)) {
// not an acf wysiwyg field
return
}
console.log(e.editor); // the editor
console.log(e.editor.id); // the editor id
e.editor.on('input', function(ed) {
// fires on any input to this editor
// could also use change, blur, focus, etc...
// you'd want to check the editor ID to match it
// to only the one you want to add this action to
console.log('input');
});
}); // end tinyMCE.on
}); // end jQuery(document).ready
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.