Lucas
Lucas

Reputation: 2886

Rails: tinyMCE won't load with my partial

Once more, I'll need your help with Rails. This time, I've a problem with tinyMCE. I can get it working on my project but not when I'm trying to render a partial.

Ok, so what I'm trying to do is displaying a collection of textarea with tinyMCE. For that, I call a partial. Let me show you my code, it would be easier to understand.

So i have my template where I want to display everything:

#index.html.erb
<% if !@online_cv_fields.empty? then %>
   <%= render :partial => 'online_cv_fields/form', :collection => @online_cv_fields %>
<% end %>

Then the partial i'm calling

<%= form_for(form) do |f| %>
   <% if form.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(form.errors.count, "error") %> prohibited this online_cv_field from being saved:</h2>

      <ul>
      <% form.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :field_name %><br />
    <%= f.text_field :field_name %>
  </div>
  <div class="field">
    <%= f.label :field_content %><br />
    <%= f.text_area :field_content, :class => "mceEditor" %>
  </div>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

And I'm loading my javascript in my application layout

  <%= javascript_include_tiny_mce_if_used %>
  <%= tiny_mce if using_tiny_mce? %>

My problem is that the Javascript won't load for the index. Even if I try to "force" the application to load tinyMCE with

  <%= javascript_include_tiny_mce %>
  <%= tiny_mce  %>

It just doesn't work.

Any clue?

Thanks !

Upvotes: 1

Views: 912

Answers (1)

Dominic
Dominic

Reputation: 1304

What mode are you using? Does TinyMCE know you want you want it to pick up the 'mceEditor' class? See: http://tinymce.moxiecode.com/wiki.php/Configuration:mode and http://tinymce.moxiecode.com/wiki.php/Configuration:elements

You might also like to try TinyMCE Hammer: http://tinymcehammer.lanalot.com/

Upvotes: 1

Related Questions