2

This answer explains how to, for example, remove the menubar and status bar for all form fields in tinyMCE:

tinymce.init({
    selector: "textarea",
    menubar:false,
    statusbar: false,
    ..
});

My question is: how can I do that for individual text areas? ie I would like some to have status bars and others not to..

Community
  • 1
  • 1
abbood
  • 23,101
  • 16
  • 132
  • 246

3 Answers3

5

You need to give your textarea element an id and then use it in every configuration:

tinymce.init({
    selector: "textarea#editor1",
    menubar:false,
    statusbar: false,
    ...
});

<textarea id="editor1"></textarea>

tinymce.init({
    selector: "textarea#editor2",
    // standard toolbar for editor 2
    ...
});

<textarea id="editor2"></textarea>

// and so on...

This way you tell tinyMCE for which textarea the configuration is in effect. Have a look at the advanced example on the tinyMCE site:

selector: "textarea#elm1",
Select only the textarea with ID elm1

UPDATE

Yes, it is possible. You need to set a unique id for all editors, but it is possible to select multiple id's at once like this:

    <script type="text/javascript">
        tinymce.init({
            selector: "textarea#common1,textarea#common2",
            theme: "modern",
            height: 100,
            menubar:false,
            statusbar: false
        });

        tinymce.init({
            selector: "textarea#comment_toolbox",
            theme: "modern",
            height: 100,
            toolbar: false
        });                     
    </script>
</head>
<body>
    <div width="100%" height="100%">
        <textarea id="common1"></textarea>
        <br/>
        <textarea id="comment_toolbox"></textarea>
        <br/>
        <textarea id="common2"></textarea>
        <br/>           
    </div>
</body>

The site looks as expected:

enter image description here

keenthinker
  • 7,645
  • 2
  • 35
  • 45
  • interesting.. is it possible to create generic settings and one that's more specific? [this](https://gist.github.com/abbood/10358597) is what i'm trying to do (but it ain't working so far) – abbood Apr 10 '14 at 08:56
  • good stuff man.. awarded you correct answer (thanks for your patience with me).. I also [shared](http://stackoverflow.com/a/22983811/766570) my way of implementing your idea, DRY style :p – abbood Apr 10 '14 at 09:20
  • Glad, that the answer helped! :) – keenthinker Apr 10 '14 at 16:18
1

this is based off pasty's answer above, it keeps it as DRY as possible:

this.setupRichTextEditorSettings = function() {
    var regularElements = ['eobjs','emats','eprocs','eclos','ehoms'];
    var specialElements = ['comment_box'];

    var convertToSelectors = function(elements) {
        return $.map(elements, function(element) {
            return "textarea#"+element;
        });
    };
    var regularElementSelectors = convertToSelectors(regularElements);
    var specialElementSelectors = convertToSelectors(specialElements);

    tinymce.init({
        selector: regularElementSelectors.join(','),
        menubar: false,
        statusbar: false
    })

    tinymce.init({
        selector: specialElementSelectors.join(','),
        menubar: false,
        statusbar: false,
        toolbar: false
    })

};
Community
  • 1
  • 1
abbood
  • 23,101
  • 16
  • 132
  • 246
0

Use a selector like this:

$('textarea#mytext').tinymce({
 menubar:false,
 statusbar: false,
 ..
});
René Roth
  • 1,979
  • 1
  • 18
  • 25