【问题标题】:Multiple epiceditors on one page一页上有多个史诗编辑器
【发布时间】:2015-05-25 17:37:22
【问题描述】:

在我的项目中,我有两个用于两个语言环境的表单,所以我在一页上有两个 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>

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)
  });  

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

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

【问题讨论】:

    标签: javascript jquery ruby-on-rails epiceditor


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      • 1970-01-01
      • 1970-01-01
      • 2019-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多