<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[TinyMCE Forum - Tip: toogle button to enable/disable TinyMCE]]></title>
		<link>http://www.tinymce.com/forum/viewtopic.php?id=436</link>
		<description><![CDATA[The most recent posts in Tip: toogle button to enable/disable TinyMCE.]]></description>
		<lastBuildDate>Sun, 04 Dec 2011 15:46:00 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=96964#p96964</link>
			<description><![CDATA[<p>I&#039;ll try contribute with my simple suggestion. But my english is so poor, so I even dont know if I have touch point of yours problem.<br />I was looking only for simple solution for just turn off tinyMCE for certain textarea. Without any possibilities turn it again on. <br />And code is:</p><div class="quotebox"><blockquote><p>&lt;body onload=&quot;tinyMCE.execCommand( &#039;mceRemoveControl&#039;, false, &#039;IDyourTextarea&#039; );&quot;&gt;</p></blockquote></div><br /><p>..only what you need is change id of your text area!<br />I hope it will help someone, cheers!</p>]]></description>
			<author><![CDATA[dummy@example.com (bozoou)]]></author>
			<pubDate>Sun, 04 Dec 2011 15:46:00 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=96964#p96964</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=84482#p84482</link>
			<description><![CDATA[<p>It took me a little while to realize that the code at the beginning of this thread is for TinyMCE 2.x.&nbsp; Here&#039;s a modified version that seems to work properly for 3.x: </p><div class="codebox"><pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  var tinyMCEmode = true; 
  function toggleEditorMode(editor, link) { 
    try { 
      if(tinyMCEmode) { 
        tinyMCE.execCommand( &#039;mceRemoveControl&#039;, false, editor );
        tinyMCEmode = false; 
        link.innerHTML = &#039;Edit with textarea&#039;;
      } else { 
        tinyMCE.execCommand( &#039;mceAddControl&#039;, true, editor );
        tinyMCEmode = true; 
        link.innerHTML = &#039;Edit with TinyMCE&#039;;
      } 
    } catch(e) { 
      //error handling 
    } 
  }
&lt;/script&gt;</code></pre></div><p>Then call with:</p><p>&lt;button onclick=&quot;toggleEditorMode(&#039;Editor&#039;, this)&quot;&gt;Edit with textarea&lt;/button&gt;</p><p>or</p><p>&lt;a href=&quot;#&quot; onclick=&quot;toggleEditorMode(&#039;Editor&#039;, this)&quot;&gt;Edit with textarea&lt;/a&gt;</p>]]></description>
			<author><![CDATA[dummy@example.com (jshaas)]]></author>
			<pubDate>Fri, 31 Dec 2010 18:25:58 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=84482#p84482</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=80641#p80641</link>
			<description><![CDATA[<p>Just my simple experience. To remove the editor on a page that has only one tinyMce instance : <strong>tinyMCE.activeEditor.hide();</strong></p>]]></description>
			<author><![CDATA[dummy@example.com (cremedios)]]></author>
			<pubDate>Wed, 22 Sep 2010 10:22:07 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=80641#p80641</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=51017#p51017</link>
			<description><![CDATA[<p>I have a function onInit;</p><p>function unlockKlasik() {<br />&nbsp; &nbsp;&nbsp; $(&#039;klasikeditor&#039;).style.visibility = &#039;visible&#039;;<br />}</p><p>So it makes this button visible after tinyMCE is loaded;</p><p>However, if user is fast to click on it (which toggles editor like in official examples), it gives such error...</p><p>tinymce.getBody() is null</p><p>or another error is<br />h is undefined (in tinymce.js)</p><p>How to fix those?</p>]]></description>
			<author><![CDATA[dummy@example.com (SiSL)]]></author>
			<pubDate>Fri, 13 Mar 2009 23:11:08 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=51017#p51017</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=51014#p51014</link>
			<description><![CDATA[<p>This thread has been extremely helpful to me, so I&#039;ll post my solution that incorporates a couple of the posts and addresses the question of how to get the text area to NOT be TinyMCE enable when loaded.</p><p>Here&#039;s the javascript:</p><p>function showMCE(id,linkObj) {<br />&nbsp; &nbsp; if (tinyMCE.getInstanceById(id) == null) {<br />&nbsp; &nbsp; &nbsp; &nbsp; linkObj.innerHTML = &quot;Advanced&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; tinyMCE.mode = &quot;specific_textareas&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; tinyMCE.execCommand(&#039;mceAddControl&#039;, false, id);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; else {<br />&nbsp; &nbsp; &nbsp; &nbsp; linkObj.innerHTML = &quot;Show Editor&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; tinyMCE.execCommand(&#039;mceRemoveControl&#039;, false, id);<br />&nbsp; &nbsp; }<br />}</p><br /><br /><p>tinyMCE.init({<br />&nbsp; &nbsp; // General options<br />&nbsp; &nbsp; mode: &quot;none&quot;,<br />&nbsp; &nbsp; editor_selector: &quot;mceEditor&quot;,<br />&nbsp; &nbsp; theme : &quot;advanced&quot;,<br />&nbsp; &nbsp; relative_url : true,<br />&nbsp; &nbsp; document_base_url : &quot;<a href="http://xxx.xxx.xxx.xxx/">http://xxx.xxx.xxx.xxx/</a>&quot;,<br />&nbsp; &nbsp; plugins : &quot;safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager&quot;,<br />&nbsp; &nbsp; cleanup : false,<br />&nbsp; &nbsp; verify_html : false,<br />&nbsp; &nbsp; apply_source_formatting : false,<br />&nbsp; &nbsp; forced_root_block : false,<br />&nbsp; &nbsp; force_br_newlines : true,<br />&nbsp; &nbsp; force_p_newlines : false,<br />&nbsp; &nbsp; </p><br /><br /><br /><p>&nbsp; &nbsp; // Theme options<br />&nbsp; &nbsp; theme_advanced_buttons1 : &quot;newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect&quot;,<br />&nbsp; &nbsp; theme_advanced_buttons2 : &quot;cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor&quot;,<br />&nbsp; &nbsp; theme_advanced_buttons3 : &quot;tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen&quot;,<br />&nbsp; &nbsp; theme_advanced_buttons4 : &quot;insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage&quot;,<br />&nbsp; &nbsp; theme_advanced_toolbar_location : &quot;top&quot;,<br />&nbsp; &nbsp; theme_advanced_toolbar_align : &quot;left&quot;,<br />&nbsp; &nbsp; theme_advanced_statusbar_location : &quot;bottom&quot;,<br />&nbsp; &nbsp; theme_advanced_resizing : true,</p><p>&nbsp; &nbsp; // Example content CSS (should be your site CSS)<br />&nbsp; &nbsp; content_css : &quot;css/example.css&quot;,</p><p>&nbsp; &nbsp;&nbsp; external_image_list_url : &quot;image_list.php&quot;<br />&nbsp; &nbsp; <br />});</p><br /><p>And the href for enabling TinyMCE is:<br />&lt;a href=# onClick=showMCE(&#039;HomepageLinkDisplay&#039;,this);&gt;Show Editor&lt;/a&gt;</p><p>The line </p><p>mode: &quot;none&quot;,</p><p>in the init is what makes it disabled at first and then the line </p><p>tinyMCE.mode = &quot;specific_textareas&quot;;</p><p>in the showMCE function is what turns it on.</p><p>Again, thanks for all the posts in this thread.</p><p>Rick</p>]]></description>
			<author><![CDATA[dummy@example.com (mandolinrick)]]></author>
			<pubDate>Fri, 13 Mar 2009 19:20:19 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=51014#p51014</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=48447#p48447</link>
			<description><![CDATA[<p>Does this work with tinymce_3_2_1_1? I think it needs an update.</p><p>Bill</p>]]></description>
			<author><![CDATA[dummy@example.com (mussatto)]]></author>
			<pubDate>Thu, 29 Jan 2009 20:01:19 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=48447#p48447</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=39199#p39199</link>
			<description><![CDATA[<p>Mr Administrator: A question and excusme because I&#039;m new in tinymce and for my inglish: Can I add buttons dinamically in tinymce???, for example with an array? and why not?<br />Thank you!!!</p>]]></description>
			<author><![CDATA[dummy@example.com (irysha)]]></author>
			<pubDate>Wed, 02 Jul 2008 13:54:35 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=39199#p39199</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=36175#p36175</link>
			<description><![CDATA[<div class="codebox"><pre><code>var hideTiny = function(id,textLink)
{
    if(tinyMCE.get(id).isHidden())
    {
        tinyMCE.get(id).show();
        textLink.innerHTML = &#039;[Hide]&#039;;        
    } else {
        tinyMCE.get(id).hide();
        textLink.innerHTML = &#039;[Show]&#039;;                
    }
}</code></pre></div><div class="codebox"><pre><code>&lt;a href=&quot;javascript:;&quot; onmousedown=&quot;hideTiny(&#039;elm1&#039;,this);&quot;&gt;[Hide]&lt;/a&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (cmacias)]]></author>
			<pubDate>Thu, 24 Apr 2008 10:49:48 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=36175#p36175</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=31207#p31207</link>
			<description><![CDATA[<p>I was wondering if you could apply this code to toggle it on and off in the b2evolution plugin. It is different and I can&#039;t seem to find any of the files needed. Is there an easy way to modify the b2evolution plugin so you can toggle it. It would save me having to go into the plugins page and manually disabling it. I can add a link on the write a post page but I&#039;m unsure what code to edit.</p>]]></description>
			<author><![CDATA[dummy@example.com (Jamiebtd)]]></author>
			<pubDate>Fri, 25 Jan 2008 09:09:48 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=31207#p31207</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=23870#p23870</link>
			<description><![CDATA[<p>I have followed the comments here and now I have a nice on/off button for my text areas. <img src="http://www.tinymce.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>However, when the page loads tinymce starts - I want to disable the editor by DEFAULT and only enable it if the &quot;toggle editor&quot; link is clicked.</p><p>Taking this code I tried it but it didn&#039;t work:<br />&lt;code&gt;<br />var tinyMCEmode = true;<br />&nbsp; &nbsp; function toogleEditorMode(sEditorID) {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;try {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(tinyMCEmode) {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tinyMCE.execCommand(&quot;mceRemoveControl&quot;, false, sEditorID);<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tinyMCEmode = false;<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tinyMCE.execCommand(&quot;mceAddControl&quot;, false, sEditorID);<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tinyMCEmode = true;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tinyMCE.init({<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //..........<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //..........</p><p>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;} catch(e) {<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//error handling<br />&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; }<br />&lt;/code&gt;</p>]]></description>
			<author><![CDATA[dummy@example.com (Xeoncross)]]></author>
			<pubDate>Tue, 19 Jun 2007 20:35:36 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=23870#p23870</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=23648#p23648</link>
			<description><![CDATA[<p>Yes Even I have a requirement that all the html added by tinyMCE should be removed when I disable the tineMCE.<br />Could any body help me please</p>]]></description>
			<author><![CDATA[dummy@example.com (kdeepak)]]></author>
			<pubDate>Thu, 14 Jun 2007 04:05:22 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=23648#p23648</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=23332#p23332</link>
			<description><![CDATA[<p>Hi,</p><p>Quick question (and I did do a search before hand but couldn&#039;t find anything). When I do a mceRemoveControl on my edited div I end up with an extra input tag - &lt;input id=txtarea type=hidden name=txtarea&gt;. The div I was editing has an id=txtarea as well. Is there a reason for this, I can&#039;t help but feel that having 2 elements with the same id is bad and my gut instinct tells me that I should locate and remove this after doing the mceRemoveControl.</p>]]></description>
			<author><![CDATA[dummy@example.com (MarkD)]]></author>
			<pubDate>Wed, 06 Jun 2007 23:17:04 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=23332#p23332</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=22841#p22841</link>
			<description><![CDATA[<p>test. TEST. Test...</p>]]></description>
			<author><![CDATA[dummy@example.com (Lagunatic)]]></author>
			<pubDate>Fri, 25 May 2007 21:50:38 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=22841#p22841</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=21602#p21602</link>
			<description><![CDATA[<p>To donadoni - Thanks! You&#039;ve helped me a lot. The &lt;---Style---&gt; selector became unavailable after submit, not allowing any changes after viewing the final result. I&#039;ve used your script with some alterations to disable/enable the editor after submit, and now the &lt;---style---&gt; menu is back!</p>]]></description>
			<author><![CDATA[dummy@example.com (yael8765)]]></author>
			<pubDate>Wed, 25 Apr 2007 19:14:15 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=21602#p21602</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tip: toogle button to enable/disable TinyMCE]]></title>
			<link>http://www.tinymce.com/forum/viewtopic.php?pid=19587#p19587</link>
			<description><![CDATA[<p>Okay, I hope I am not duplicating too much info...</p><p>Personally I wanted the functionality of being able to turn every textarea in the document into a TinyMCE instance or back by having a graphic as a &quot;button&quot; (usnign its onclick event) next to the textarea, and I wanted that automated so that I didn&#039;t have to do anything; additionally, I wanted this only if JavaScript was activated, because otherwise the editors wouldn&#039;t work anyway, so&nbsp; the &quot;buttons&quot; should be created script-wise, too. Sure, adds to the page&#039;s setup overhead, but hey, only for people with JavaScript anyway...</p><p>Here is what to do. First you need to add something to the configuration:</p><div class="codebox"><pre><code>tinyMCE.init({ 
  ...
  mode : &#039;none&#039;,
  ...
  oninit : &#039;createToggleButtons&#039;
});</code></pre></div><p>The &quot;oninit&quot; part denominates a function that is called after the initial page setup of TinyMCE (see in the <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/oninit">http://wiki.moxiecode.com/index.php/Tin &#133; ion/oninit</a>).</p><p>The function that is called is this one:</p><div class="codebox"><pre><code>function createToggleButtons()
{
  var textareas = document.getElementById(&#039;maincontent&#039;);
  if(!textareas) return false;
  textareas = textareas.getElementsByTagName(&#039;textarea&#039;);
  for(var i = 0; i &lt; textareas.length; ++i){
    var img_element     = document.createElement(&#039;img&#039;);
    img_element.src     = &#039;path/to/img.png&#039;;
    img_element.alt     = &#039;Turn editor mode on/off&#039;;
    img_element.onclick = toggleTinyMCE;
    textareas.parentNode.insertBefore(img_element, textareas);
  }
}</code></pre></div><p>It provides all textareas that are descendants of the element with the id &quot;maincontent&quot; with an image whose onclick event handler is set to a function toggleTinyMCE(). If you want it more general, make the first three lines into this:<br /></p><div class="codebox"><pre><code>textareas = document.getElementsByTagName(&#039;textarea&#039;);</code></pre></div><p>Make sure to provide sensible contents for the src and alt attributes of the image :-)</p><p>Finally the event handler function, toggleTinyMCE():<br /></p><div class="codebox"><pre><code>function toggleTinyMCE(event)
{
  var editor_button = event.target;
  var editor_id = editor_button.nextSibling.id;

  if(typeof(editor_button[&#039;curTinyMCE_element&#039;]) == &#039;undefined&#039;)
    editor_button.curTinyMCE_element = false;

  if(editor_button.curTinyMCE_element) {
    tinyMCE.removeMCEControl(tinyMCE.getEditorId(editor_id));
    editor_button.curTinyMCE_element = false;
  } else {
    tinyMCE.addMCEControl(editor_button.nextSibling, editor_id);
    editor_button.curTinyMCE_element = true;
  }
}</code></pre></div><p>That is pretty much it.</p><p>You can easily put all the code including the initialization code into one file.</p>]]></description>
			<author><![CDATA[dummy@example.com (hihp)]]></author>
			<pubDate>Fri, 23 Feb 2007 15:59:53 +0000</pubDate>
			<guid>http://www.tinymce.com/forum/viewtopic.php?pid=19587#p19587</guid>
		</item>
	</channel>
</rss>
