3

I am reusing a tinymce control in an application. Basically I open the tinymce toolbar on the click of a link / button. I use the toolbar to select for instance bold or undo some text and then close the tinymce. When I open the tinymce again for another link / button the toolbar selections I had made the first time still seem to be clicked. For instance:

Opening tinymce first time, I select bold:

enter image description here

I then simply close the tiny mce and later open it up for another field, when I open it up for another field the B setting is still enabled (button is pushed in as shown in the image above). Is there a way to programitically reset the toolbar selections upon opening the tinymce. I looked at their documentation and found nothing

JonH
  • 31,954
  • 11
  • 81
  • 141

2 Answers2

1

Check this fiddle. This will clear any formatting if previously exists and will also reset all formatting buttons in case you have an empty editor.

tinymce.activeEditor.execCommand('selectAll');
tinymce.activeEditor.execCommand('RemoveFormat');

These two lines do this, select all content and then remove format.Best part is it works even when you have empty tinymce editor.

EDIT To serve your purpose, when an editor is opened, just click on "Bold" button and then click on the "remove format" button we have included. This will reset the "Bold" button clicked.

tushar.dahiwale
  • 150
  • 2
  • 13
0

A way you can try is reloading the entire tinyMCE. Try using this code in order to remove it:

tinyMCE.execCommand('mceRemoveControl', true, 'editor_id');

And then init it again:

tinyMCE.init({
  /* TinyMCE options */
 });
}
Alfonso Jiménez
  • 1,215
  • 1
  • 13
  • 24