How to enable multiple TinyMCE in the same form

人盡茶涼 提交于 2019-12-11 05:47:16

问题


I want to use 2 different textareas with tinyMCE in the same form. The first one works well but whenever I am adding the 2nd one, the 2nd one disabled (it enables when I enlarge it manually from bottom right corner). Their field name and id is different.

Can anyone tell me how can I fix this problem?

Thanks in advance.


回答1:


Since there is no code from you we cant figure out where your problem is. Maybe to go a way around, init TinyMce for both Textareas over a class:

<script type="text/javascript" src="<your installation path>/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
        mode : "textareas",
        theme : "simple",
        editor_selector : "mceSimple"
});

tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        editor_selector : "mceAdvanced"
});
</script>

<form method="post" action="somepage">
        <textarea name="content1" class="mceSimple" style="width:100%">
        </textarea>
        <textarea name="content2" class="mceAdvanced" style="width:100%">
        </textarea>
</form>

Cheers, Stefan




回答2:


If you resize the tinymce's area, the text magically appears.

Mikko Huilaja's javascript solution:

<script type="text/javascript">

$(window).load(function() { 
  forceTinyMceIframeResize(); 
});

function forceTinyMceIframeResize() { 
  $('.mceEditor .mceIframeContainer iframe').each(function(i) { 
    $(this).height($(this).height()+1); 
  }); 
}
</script>



回答3:


Use a common class (e.g tinymce-editor) for all the text area for which you need to add TinyMCE.

Then in HTML head section add the following code to initialize TinyMCE.

$(function(){
   tinyMCE.init({
    selector: '.tinymce-editor',
    statusbar: false,
    min_height: 120,
    menubar: false,
    toolbar: 'styleselect | bold italic underline | undo redo | image | link',
    plugins: 'image, link',
    forced_root_block: false,
    default_link_target: "_blank",
    link_assume_external_targets: true 
   });
}); 


来源:https://stackoverflow.com/questions/9783141/how-to-enable-multiple-tinymce-in-the-same-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!