TinyMCE 在重新插入到文档中后使用。

huangapple go评论69阅读模式
英文:

TinyMCE use after being reinserted into document

问题

I'm having a difficult time making TinyMCE work after it has been removed from the document and then re-inserted. I've created this TinyMCE Fiddle to demonstrate the issue: https://fiddle.tiny.cloud/F8iaab/3 .

To see the issue:

  1. Click the "Init / re-init TinyMCE" button. This will initialise TinyMCE below the buttons.
  2. Now click "Remove content" to remove the container from the document
  3. Click the "Append content" button to put it back in
  4. Finally, click the first button again - its impossible to enter text into the editor.

The final step is based on other discussions I've found on this topic (references below).

Any ideas how I can make a TinyMCE instance usable after being reinserted into a document?

Refs:

英文:

I'm having a difficult time making TinyMCE work after it has been removed from the document and then re-inserted. I've created this TinyMCE Fiddle to demonstrate the issue: https://fiddle.tiny.cloud/F8iaab/3 .

To see the issue:

  1. Click the "Init / re-init TinyMCE" button. This will initialise TinyMCE below the buttons.
  2. Now click "Remove content" to remove the container from the document
  3. Click the "Append content" button to put it back in
  4. Finally, click the first button again - its impossible to enter text into the editor.

The final step is based on other discussions I've found on this topic (references below).

Any ideas how I can make a TinyMCE instance usable after being reinserted into a document?

Refs:

答案1

得分: 1

Seems to work if you remove the tinymce instance when removing content.

function removeContent() {
container.parentNode.removeChild(container);
var editor = tinymce.get('content');
if (editor) {
editor.remove();
}
}
Fiddle.

英文:

Seems to work if you remove the tinymce instance when removing content.

function removeContent() {
	container.parentNode.removeChild(container);
	var editor = tinymce.get('content');
	if (editor) {
	    editor.remove();
	}
}

Fiddle.

huangapple
  • 本文由 发表于 2023年5月25日 23:12:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76333842.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定