1

In my project I have two forms for two locales, so I have two EpicEditors on one page. However, it does not work well.

_form.html.erb

  <div id="tabs-1">
    <%= f.globalize_fields_for :ru do |g| %>

      <div class="form-inputs">
        <%= g.input_field :title, placeholder: t('.course_title') %>

        <div id="epiceditor">
        </div>

        <%= g.input_field :description, id: "epiceditor-textarea" %>

      </div>
    <% end %>
  </div>

  <div id="tabs-2">
    <%= f.globalize_fields_for :en do |g| %>

      <div class="form-inputs">
        <%= g.input_field :title, placeholder: t('.course_title') %>

        <div id="epiceditor">
        </div>

        <%= g.input_field :description, id: "epiceditor-textarea" %>

      </div>
    <% end %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, t('.save'), class: "pull-right" %>
  </div>

application.js

  function LoadEditor(element) {
      new EpicEditor({
        container: element,
        textarea: '#epiceditor-textarea',
        theme: {
          preview: '/assets/application.css'
        }
      }).load();
    }

  $("#epiceditor").each(function(index, element) {
    LoadEditor(element)
  });  

What can you suggest I do? Of course I can call method LoadEditor two times, but I think it is not a good solution, because then I will add more locales, maybe.

Using this code I have error:
Uncaught TypeError: Cannot read property 'value' of null

Oscar Godson
  • 28,084
  • 40
  • 103
  • 191

1 Answers1

0

I have given a detailed answer at https://stackoverflow.com/a/35285968/936494. It shows passing custom options and how to use that to instantiate EpicEditor. Please have a look at it and try using the code given. I am sure it will be helpful.

Community
  • 1
  • 1
Jignesh Gohel
  • 5,425
  • 4
  • 46
  • 82