我想用tinyMCE编辑器使用jQuery replaceWith()更改一些文本,这对于replaceWith()函数本身没有问题,但我不知道如何将tinyMCE编辑器实现到新的textarea。
<div id="div">Some text</div>单击编辑按钮时,将更改为
<textarea id="new">Some text</textarea> (with tinyMCE editor)我试过两种方法,
1.更换前初始化选择器 - 不工作
tinymce.init({ selector: "#input_insertComment",2. - 使用tinymce实例(?) - 不工作
$('#div').replaceWith("<textarea id=new>some text</textarea>"); tinymce.initMCEexact("#new");编辑器都没有实现。 我怎样才能做到这一点?
(在同一页面上,我有另一个文本区域的tinymce编辑器。)
I want to change some text with tinyMCE editor using jQuery replaceWith(), It's no problem with replaceWith() function itself, but I don't know how to implement tinyMCE editor to new textarea.
<div id="div">Some text</div>When edit button clicked, will change to
<textarea id="new">Some text</textarea> (with tinyMCE editor)I tried 2 ways,
1. Init tinymce selector before replacing - not working
tinymce.init({ selector: "#input_insertComment",2. - useing tinymce instance(?) - not working
$('#div').replaceWith("<textarea id=new>some text</textarea>"); tinymce.initMCEexact("#new");Both the editor aren't implemented. How can I do that?
(At the same page, I have tinymce editor for another textarea.)
最满意答案
当你调用tinymce.init()它只会在你调用init()时影响DOM中存在的项目。 如果您稍后向页面添加元素,则init()调用将不会用TinyMCE替换它们。
你想要的顺序是......
将textarea添加到DOM 调用tinymce.init()并使用init中的selector选项来定位刚刚添加到页面的textarea。我不知道tinymce.initMCEexact()是一个真正的API调用,它曾经是TinyMCE的一部分 - 它肯定不是TinyMCE 4的一部分。
When you call tinymce.init() it will only impact items that exist in the DOM when you call init(). If you are adding elements to the page later the init() call won't then replace them with TinyMCE.
The sequence you want is...
Add the textarea to the DOM Call tinymce.init() and use the selector option in the init to target the textarea that you just added to the page.I am not aware of tinymce.initMCEexact() as an actual API call that was ever part of TinyMCE - its not part of TinyMCE 4 for sure.
更多推荐
发布评论