[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

TinyMCE - Toggle controls for different textareas

Posted on 2009-04-28
1
Medium Priority
?
743 Views
Last Modified: 2012-05-06
Hi folks,

The code below initialises TinyMCE and doesnt load it into any text area which is exactly what I want - When I click on the toggle button for a particular control it loads in the TinyMCE editor fine (only since i added the id=document.getElementById(id) part) but when I click the toggle button on another textarea it unloads the control from the previous textarea, and when i click the this button again it then loads into this new <textarea>

I have about 10 <textarea> on my form, and i basically want to load controls in and out of these when the user requires. Can anyone point me in the right direction?

Browser: IE 7


tinyMCE.init({
 
        mode : "none", 
 
        theme : "advanced"
 
    });
 
function toggleEditor(id) 
{
 
    id = document.getElementById(id);
 
    if (!tinyMCE.get(id))
        tinyMCE.execCommand('mceAddControl', true, id);
    else
        tinyMCE.execCommand('mceRemoveControl', true, id);
}
 
<textarea name="MyTextArea" style="width:100%">
      </textarea>
<a href="javascript:toggleEditor('MyTextArea');">Enter text</a>

Open in new window

0
Comment
Question by:DevSure
1 Comment
 
LVL 15

Accepted Solution

by:
OMC2000 earned 2000 total points
ID: 24251237
You don't need getElementById, I guess the problem was in undefined ID attribute for your textarea. Check the following:

function toggleEditor(id)
{
    if (!tinyMCE.get(id))
        tinyMCE.execCommand('mceAddControl', true, id);
    else
        tinyMCE.execCommand('mceRemoveControl', true, id);
}

<textarea name="MyTextArea" id="MyTextArea"  style="width:100%">
      </textarea>
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month18 days, 5 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question