Reputation: 87
Is there a way to prevent tinymce from auto-focusing on mode change?
What I was trying to achieve is that, enable/disable the editor based on the status of parent field.
let mode = isDisabled ? 'readonly' : 'design';
this.editor.setMode(mode);
Whenever i call the code above, the editor will be auto-focused. My expectation is to remain the focus on parent field even if the status of the parent field has changed. The version of TinyMCE i use is 4.7.4
Upvotes: 1
Views: 1252
Reputation: 1629
I was able to prevent my editor from gaining focus by using the following instead of setMode():
tinymce.get(id).getBody().setAttribute('contenteditable',false); // readonly
tinymce.get(id).getBody().setAttribute('contenteditable',true); // design
ref: disable TinyMCE text editor via Jquery
Upvotes: 1