spohlenz / tinymce-rails

Integration of TinyMCE with the Rails asset pipeline
Other
816 stars 258 forks source link

Does tinymce-rails conflict with either simple-form or twitter-bootstrap-rails gems? #72

Closed bakki closed 11 years ago

bakki commented 12 years ago

TinyMCE works if I unpack the distro in vendor/assets and do manual config. But the problem then is that asset pipeline screws things up on deploy. I tried local asset compile without success. Now I am having trouble getting the editor to render with tinymce-rails gem in development env. Here's my configuration.

Gemfile:

...... gem 'twitter-bootstrap-rails' gem 'simple_form' gem 'tinymce-rails' ......

tinymce.yml: theme_advanced_toolbar_location: top theme_advanced_toolbar_align: left theme_advanced_statusbar_location: bottom theme_advanced_buttons3_add:

application.js: //= require jquery //= require jquery-ui //= require jquery_ujs //= require tinymce-jquery //= require twitter/bootstrap //= require_tree .

In application.html.erb:

<script type="text/javascript">
  tinyMCE.init({
    mode : "specific_textareas",
    editor_selector : "mceEditor",
    theme: 'advanced'
  });

In _from partial:

    <%= f.input :body, :input_html => { :class => 'mceEditor' } %>

(I tried to init the editor here without success).

I see that all the js files GET ok. The generated html for the textarea:

<textarea class="text optional mceEditor" cols="40" id="message_body" name="message[body]" rows="20" style="margin: 0px; width: 292px; height: 380px;"></textarea>

Can some one see what I am doing wrong here? Is there some load order magic going on?

Thank you.

-bakki

bakki commented 12 years ago

I got it working in the development env by deleting the manual init and replacing with <%= tinymce %> just after the textarea tag. I also deleted the require tinymce in my application.js and instead put in the assets helper in the body section instead of head. I had noticed that here was a javascript error, in the console (chrome developer tools), t tinyMCE not defined, where I was trying to init tinyMCE in the partial. I did this by more of trial and error rather than real understanding of why it wasn't working when the asset helper was in the head section. Next big step will be to see deployment also works.

archonic commented 11 years ago

I'm also getting tinyMCE is not defined although my bootstrap is included manually. I've tried <%= tinymce %> just after the text area and in the footer of application.html.erb. Not sure what I'm doing wrong.

bcackerman commented 11 years ago

The key is to call the JS for TinyMCE at the top of your page

alapp commented 11 years ago

bcackerman, you're my hero.