在我的项目中,我有两种语言环境的两种形式,所以我在一页上有两个 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 的属性“值”