2

Oh hai

I have an ajax request, which works way:

  • request starts: tinyMCE gets disabled (controls are removed)
  • request ends: tinyMCE gets reinitialized because the DOM changes, so basically a new editor is instantiated.

The problem is that for 1-2 seconds I'm seeing the editor controls being removed, then added again when the ajax completes.

Is there any way I could avoid this? By removing the editor somehow in the background for example?

I tried leaving out tinyMCE.execCommand('mceRemoveControl', false, editor); before the ajax starts, but then I can't get the editor back... Which is kind of weird because the text area gets replaced. It seems that tinyMCE stays in memory somehow or something

Alex
  • 66,732
  • 177
  • 439
  • 641

2 Answers2

2

It seems that tinyMCE stays in memory somehow or something

Yes, this is true. The tinyMCE object keeps track of all editor instances that have been created. When an editor gets reinitialized with the same id you will get into trouble. that's the reason why you need to shut down tinymce instances correctly.

I see another option. You do not need to replace the textarea. Why don't you just reset the tinymce editor content?

Thariama
  • 50,002
  • 13
  • 138
  • 166
1

setTimeout... may solve that problem...

window.setTimeout(function(){ tinyMCE.execCommand('mceFocus', false, 'editor');}, 500);
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
Bharat Gaikwad
  • 530
  • 2
  • 5
  • 16
  • 1
    Please **never** pass a string to setTimeout. – ThiefMaster Nov 13 '11 at 17:04
  • 1
    ok,got it,edited my ans... because it is run in the global scope, has performance issues, is potentially insecure if you're injecting any parameters,etc hence its deprecated....passing a string in setTimeout fuction... evil ;) http://stackoverflow.com/q/6081560/727154 – Bharat Gaikwad Nov 13 '11 at 17:19