tinyMCE options

家住魔仙堡 提交于 2019-12-10 16:06:51

问题


How can I toggle the readonly state in an initialized tinyMCE container?

Whilst the tinyMCE is initialised in a common javascript file, the option I want to change is specific to the logic of an individual page, and changes based on user's input via a checkbox.

This are some of the things I tried and all resulted in failure: http://pastebin.com/JEn2fyE6


回答1:


I just managed to do it this way:

Having the textarea set with id intro I do this

if($('.disabled_check').is(':checked')) {
    $('#intro_ifr').contents().find('body').attr('contenteditable', false);
}



回答2:


So you want to set this option http://www.tinymce.com/wiki.php/Configuration:readonly after the init. according to this thread: http://www.tinymce.com/forum/viewtopic.php?id=15488 it can not be done according to the folks of the tinymce forum.

This S.O. answer seems to work: Set TinyMCE Editor Param after Initialized

tinymce.activeEditor.getBody().setAttribute('contenteditable', false);

If it does not, this topic has a workaround: http://forum.morfik.com/posts/21058 create two instances of tinymce one readonly, one normal and only display the desired one.




回答3:


Please check this code

setTimeout(function () { for (var i = 0; i < tinymce.editors.length; i++) { tinymce.editors[i].getBody().setAttribute('contenteditable', false); }; },1000);




回答4:


You may set this setting after init using

tinymce.get('my_editor_id').settings.readonly = false;

But this won't influence the editor behaviour in the way you desire because the relevant part were processed while initialization.

The working approch here is what JP Hellemons already stated.



来源:https://stackoverflow.com/questions/11051093/tinymce-options

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