Ruby on rails 表单_用于内部另一个表单_用于渲染字段,但不<;表格></表格>;阿伦标签
我正在为我的Rails站点制作一个自定义编辑器,我需要使用AJAX将图像直接上传到编辑器中。我把所有的东西都记下来了,唯一的问题是,在图片中的字段,在表单中的部分,没有用标签包装。如果没有这些表单标记,我的AJAX/Javascript就无法工作 这是我的密码: 项目表格:Ruby on rails 表单_用于内部另一个表单_用于渲染字段,但不<;表格></表格>;阿伦标签,ruby-on-rails,ruby,ruby-on-rails-4,rubygems,Ruby On Rails,Ruby,Ruby On Rails 4,Rubygems,我正在为我的Rails站点制作一个自定义编辑器,我需要使用AJAX将图像直接上传到编辑器中。我把所有的东西都记下来了,唯一的问题是,在图片中的字段,在表单中的部分,没有用标签包装。如果没有这些表单标记,我的AJAX/Javascript就无法工作 这是我的密码: 项目表格: <%= form_for @project do |f| %> <h1>New Project</h1> <div class="field">
<%= form_for @project do |f| %>
<h1>New Project</h1>
<div class="field">
<%= f.label :title %>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :involvment, "Involvement" %>
<%= f.text_field :involvment %>
</div>
<div class="field">
<%= f.label :project_link, "Project Link" %>
<%= f.text_field :project_link %>
</div>
<div class="field">
<%= f.label :background, class: 'btn' do %>
Upload Image <i class="fa fa-upload" aria-hidden="true" style='margin-left: 20px'></i>
<% end %>
<%= f.attachment_field :background, direct: true, class: "hidden" %>
</div>
<%= f.fields_for :sections do |section| %>
<%= render "section_fields", f: section %>
<div class="links">
<%= link_to_add_association 'Add Section', f, :sections, class:"clickTarget" %>
</div>
<% end %>
<% end %>
新项目
上传图像
节字段/节字段
<div class="nested-fields">
<div class="field">
<%= f.label :content %>
<div class="editor">
<div class="toolbar">
<div class="toolbarItem boldText">
<div class="button bold">
<i class="fa fa-bold" aria-hidden="true"></i>
</div>
</div>
<div class="toolbarItem italicText">
<div class="button italic">
<i class="fa fa-italic" aria-hidden="true"></i>
</div>
</div>
<div class="toolbarItem underlineText">
<div class="button underline">
<i class="fa fa-underline" aria-hidden="true"></i>
</div>
</div>
<div class="toolbarItem link">
<div class="button able-active link">
<i class="fa fa-link" aria-hidden="true"></i>
</div>
<div class="toolbarSettings link">
<label for="linkBox">Insert link URL</label>
<input type="text" class="linkBox"/>
<button class="finEditor">Insert Link</button>
</div>
</div>
<div class="toolbarItem image">
<div class="button able-active image">
<i class="fa fa-picture-o" aria-hidden="true"></i>
</div>
<div class="toolbarSettings link">
<%= render 'image_fields' %>
</div>
</div>
</div>
<%= f.text_area :content, class:"editorTextarea" %>
</div>
<%= link_to_remove_association "Remove Section", f, class:"clickTarget" %>
</div>
插入链接URL
插入链接
图像/图像字段的表单
<%= form_for @image, url: new_image_path, method: :post do |image| %>
<%= image.label :image, "Upload an Image" %>
<%= image.attachment_field :image, direct: true %>
<p>Or</p>
<%= image.label :remote_image_url, "Insert Image URL" %>
<%= image.text_field :remote_image_url, id: "linkBox" %>
<button class="finEditor">Insert Image</button>
<% end %>
或
插入图像
表单元素不能嵌套。表单元素不能嵌套。