1

此时我正在使用此编辑器http://cksource.com/ckeditor 问题是当我以新表单访问时,textarea 不起作用,但如果我在浏览器中更新新表单,它可以正常工作

我的部分是这样的

<%= simple_form_for [@version, @documento], :html => { :class => 'form-horizontal' } do |f| %>

<table width="100%">
    <tr>
        <th>Nombre</th>
        <td><%= f.input :name, 
                :label      => false,
                :input_html => {:style => 'width: 380px;'} %>
        </td>
    </tr>
    <tr>
        <th>Tipo de Documento</th>
        <td>
            <%= f.association :tipo,
                :label      => false,
                :required   => true,
                :input_html => {:class => 'span2'}
            %>
            <%= link_to 'Nuevo',new_tipo_path, :remote => true %>
        </td>
    </tr>
    <tr>
        <th>Descripcion</th>
        <td><%= f.input :descripcion, 
                :label      => false, 
                :input_html => {:class => "ckeditor", :id => "descripcion"} %>
        </td>
    </tr>
</table>

<div class="form-actions">
    <%= f.button :submit, :class => 'btn btn-primary', :value => 'Guardar Documento' %>
    <%= link_to 'Cancelar', version_documentos_path(@version), :class => 'btn' %>
</div>

我能做些什么来解决这个问题?

非常感谢

4

2 回答 2

1

不确定您所看到的内容,并且您的帖子中没有列出任何错误,因此没有足够的信息可以继续,但您的表单看起来不错。

如果你不反对,你可以使用 ckeditor 的 gem。它只是 javascripts 的一个包装器,以确保一切都在资产管道中正常工作,而不会干扰您的表单。

https://github.com/tsechingho/ckeditor-rails

3 个步骤

gem 'ckeditor_rails'将 gem 添加到 Gemfile

//= require ckeditor-jquery在 application.js 中包含 js

<%= f.text_area :content, :class => 'ckeditor' %>将类添加到您的文本区域输入

于 2013-08-01T17:15:20.660 回答
0

我找到了解决方案,就像我在上一个答案中所说的那样,问题是 turbolinks

在那种情况下,当我们不想使用与 turbolinks 一起使用的链接时,我们只需要以这种方式创建一个 div

<div data-no-turbolink>
  <%= link_to 'Nuevo Documento', new_version_documento_path(@version), :class => 'btn btn-primary' %>
  <%= link_to 'Atras', versions_path , :class => 'btn'%></div>

因此,此链接不适用于 turbo 链接,但 ckeditor gem 没有任何问题

于 2013-08-02T15:20:03.633 回答