1

在我的项目中,我有两种语言环境的两种形式,所以我在一页上有两个 EpicEditor。但是,它不能很好地工作。

_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>

应用程序.js

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

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

你能建议我做什么?当然我可以调用两次 LoadEditor 方法,但我认为这不是一个好的解决方案,因为那样我可能会添加更多的语言环境。

使用此代码我有错误:
未捕获的类型错误:无法读取 null 的属性“值”

4

1 回答 1

0

我已经在https://stackoverflow.com/a/35285968/936494给出了详细的答案。它显示了传递自定义选项以及如何使用它来实例化 EpicEditor。请查看它并尝试使用给定的代码。我相信它会有所帮助。

于 2016-02-09T07:17:13.537 回答