Rails:在Bootstrap模式下编辑记录 [英] Rails: Edit record in Bootstrap modal
问题描述
我正在尝试在Rails中使用Bootstrap模态来编辑记录,但是我无法获取该模态以将范围限制为当前记录
I'm trying to use a Bootstrap modal in Rails to edit a record, but I can't get the modal to scope to the current record
静态链接为
<%= link_to "Weigh Out", edit_ticket_path(ticket), "data-toggle" => "modal", :class => 'btn btn-mini', :id => 'edit_modal_link', "data-toggle" => "modal" %>
我真的需要在id/edit上调用模式,这是工单号,但无法使其链接到表中的选定记录.
I really need to call the modal on id/edit which is the ticket number but cannot get it to link to the selected record in the table.
有什么想法吗?
还是渲染部分片段,但必须使用可用的票证调用该部分票,该票证的范围正确地取决于我们需要编辑的票证?
Or render a partial but the partial must be called with the ticket available to it is scoped correctly to the ticket we need to edit?
我的局部外观
<%= form_for @ticket, :html => { :class => 'form-horizontal' } do |f|%>
<div class="control-group">
<%= f.label :customer_name, :class => 'control-label' %>
<div class="controls">
<%= f.hidden_field :customer_id, :class => 'text_field', :id =>"cust_id" %>
<%= f.autocomplete_field :customer_name, autocomplete_customer_name_customers_path, :id_element => '#cust_id', :class => 'text_field ui-autocomplete-input' %>
</div>
需要以Modal渲染,
Which need to render in Modal,
推荐答案
另一种方法如下:
只需创建一个远程链接:
just create a remote link:
link_to "edit", edit_ticket_path(ticket), class: "btn btn-mini", remote: true
然后在您的视图中,添加一个edit.js.erb文件:
Then in your views, add a edit.js.erb file:
$("#myModal").html("<%= j render "new"%>");
$('#myModal').modal('show');
,然后将您的edit.html和new.html文件更改为_new.html和edit.html
and change your edit.html and new.html files to _new.html and edit.html
这篇关于Rails:在Bootstrap模式下编辑记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!