Plain and Rich text editor options in TinyMce editor

匆匆过客 提交于 2019-12-07 04:48:28

Well, you can take a look here:

Toggle editor with JavaScript

The code used is:

toggleEditor('content')

If you want the editor mode to be toggled based on the option chose by the user from another page, you can execute (or not to) the above function on page load.

There are links to other examples on that page which you might find useful too.

Update:

Upon reading the question a second time, you are asking for a plain-text/html and not a html-source/wysiwyg model. My suggestion above isn't the exact solution but it is still workable if the mode switching in the plain-text mode is hidden and locked.

This is what i did for my site;

<script type="text/javascript">
function changeposttype(){
    if($("#posttype option:selected").text() == 'Simple'){
        //tinymce.execCommand('mceToggleEditor',true,'new-post-desc');
        tinyMCE.execCommand('mceRemoveControl', false, 'new-post-desc'); 
    }else{
        tinyMCE.execCommand('mceAddControl', false, 'new-post-desc');
    }
}
</script>

And inside BODY tag

<select id="posttype" onchange="changeposttype()">
    <option>Rich</option>
    <option>Simple</option>
</select>
<br />
<textarea id="new-post-desc" class="PostEditor"></textarea>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!