I have developed a small application for my own use to keep track of the hours I worked for customers.
There is a page there that includes a TinyMCE editor that I use to write down the tasks done.
I've added the SAVE plugin, which allows to submit the form the TinyMCE editor is embedded into.
And I'd like to be able to set the focus back to the TinyMCE editor when the page loads after the save event.
I've tried several approaches I've found on the Internet, but none worked for me.
I am using the latest version 6.7 (today).
The way I insert TinyMCE in my form is the following one:
<script language='javascript' type='text/javascript'>
tinyMCE.init({
selector: '#notes',
plugins: 'lists table save',
toolbar: 'bullist numlist bold italic underline strikethrough subscript superscript indent outdent forecolor backcolor table save',
width : '".$width."',
height : '".$height."',
branding: false,
menubar:false,
browser_spellcheck: true,
resize: 'both',
});
</script>
"
notes
" is the ID of the
textarea
that becomes replaced by the TinyMCE editor instance.
Do you know of the right syntax to do this?
Thank you all for your time and help.
What I have tried:
I've tried several methods but none of this worked for me:
<script>tinyMCE.get("#notes").focus();</script>
<script>tinyMCE.get("#notes").get().focus();</script>
<script>tinyMCE.get("#notes").getBody().focus();</script>
<script>tinyMCE.get({#notes}).focus();</script>
<script>tinyMCE.get(#notes_ifr).focus();</script>
Of course, I've called all those separately (to test one by one) and after the element creation.