widjajayd
widjajayd

Reputation: 6253

Tinymce gem, Have to press reload to make tinymce toolbar available

I'm using this guideline to setup tinymce in rails

https://github.com/spohlenz/tinymce-rails

but I have small problem, each time I open page that has tinymce editor, the the text area that has tinymce attached shown blank I have to reload / refresh the browser to make it available.

is there any tips to fix this (I'm using rails 4) thank you.

tinymce.yml

menubar: false
toolbar:
  - styleselect | bold italic | undo redo | table
plugins:
  - table

news.html.erb

<%= tinymce_assets %>
<%= form_for @news do |f| %>
    <%= render 'common/form_errors', object: @news %>
    <p>
      <%= f.label :isi %><br>
      <%= f.text_area :isi, :class => "tinymce", :rows => 7, :cols => 50 %>
      <%= tinymce :content_css => asset_path('application.css') %>
    </p>
  <div class="form-action">
    <%= f.submit nil, :class => 'btn btn-primary' %>
  </div>
<% end %>

Upvotes: 0

Views: 2025

Answers (2)

ssyangy
ssyangy

Reputation: 23

Another alternative could be this:

$(document).on('ready page:load', function () {
   tinymce.remove();
   tinymce.init({selector:'textarea'});
});

Upvotes: 2

widjajayd
widjajayd

Reputation: 6253

I think I just fixed the issue, it's because of turbolink so for every link that point to the page that has tinymce attached I disable turbolink by this option 'data-no-turbolink' => true

<%= link_to "Create News", new_news_path, 'data-no-turbolink' => true %>

Upvotes: 6

Related Questions