1
votes

Every text_area I make gets the tiny mce editor.

How to disable tinymce editor on certain text area fields?

I have followed this installation guide. https://github.com/kete/tiny_mce

My controller:

class Admin::KategorisController < Admin::AdminController
  uses_tiny_mce(:options => {  :theme => 'simple'}, :editor_selector => 'mceEditor')
end

Part of my form:

<%= f.input :name, :label => 'Navn' %>
<%= f.input :title, :label => 'URL titel' %>
<%= f.input :keywords, :label => 'Keywords' %>
<%= f..text_area :meta :cols => 80, :rows => 20, :label => 'META', :class => 'asdasd' %>
<%= f.text_area :text, :cols => 80, :rows => 20 %>

Both meta and text is a tinymce editor in view

If I use this in controller:

  uses_tiny_mce(:options => {  :theme => 'simple', :class => "mceEditor"})

I get this error:

TinyMCE::TinyMCEInvalidOption in Admin/kategoris#edit

Showing C:/Rails/konkurranceportalen/app/views/layouts/admin.erb where line #11 raised:

Invalid option class passed to tinymce

Extracted source (around line #11):

8:   <%= javascript_include_tag :defaults %>
9:   <%= javascript_include_tag "Highcharts" %>
10:     <%= javascript_include_tag :all %>
11:  <%= include_tiny_mce_if_needed %>
12:  <script type="text/javascript">
13: tinyMCE.init({
14:         height : "50px"
1

1 Answers

3
votes

Tinymce only appears chere you told it to appear ie where the class is mceEditor if you kept the default config.

So just change the class of your text area.

EDIT:

Have a close look at this taken from the doc:

Then append the following to the text area you want to transform into a TinyMCE editor. You can change the name of the class you want to use by editing the ‘editor_selector’ param in the controller code options.

:class => "mceEditor"

EDIT2:

just keep this in your controller

  uses_tiny_mce :options => {  :theme => 'simple', :editor_selector => 'mceEditor'}