【发布时间】:2019-02-18 17:35:26
【问题描述】:
我试图在用 ruby on rails 发送表单之前显示一个确认按钮。
问题是我使用的解决方案不起作用。首先,它显示了两次警报,按两次按钮后,没有发送表单,也没有任何反应。
这是我的代码
<%=form_for @transaction, :url => delete_duplicated_items_transactions_path(),:html=>{:class=>"form-horizontal bol-form"} do |f|%>
<div>
<script type="text/javascript">
var checked = false;
function selectAll(){
checked = !checked;
console.log(checked);
$("input:checkbox").each(function(){
$(this).attr('checked', checked);
});
return false;
}
</script>
<table class="admin-table data-table" id="usertable">
<thead>
<tr>
<th><input type="checkbox" onclick="selectAll()">Select All</a></th>
<th>Bill of Lading Name</th>
<th>Product Lot id</th>
</tr>
</thead>
<tbody id="bill_of_ladings_body">
<% duplicated.each do |element|%>
<tr id="row_user_<%=element["product_lot"].id%>">
<td><%= check_box_tag "product_lots[]", "#{element["bill_of_lading"].id.to_s};#{element["product_lot"].id.to_s}" %></td>
<td><%=link_to element["bill_of_lading"].name,edit_bill_of_lading_path(:id => element["bill_of_lading"].id)%></td>
<td><%= element["product_lot"].id %></td>
</tr>
<%end%>
</tbody>
</table>
</div>
<div class="admin-table data-table">
<br>
<td align="right">
<%=f.button "Remove from Bill of Ladings", name: "transaction_type",value: 'remove', :class=>"btn btn-info","data-loading-text"=>"Processing..."%>
<%=f.button "Remove from Bill of Ladings and Recycle", name: "transaction_type", value: 'remove_and_recycle', data:{confirm:'If you proceed, the system will delete the selected Lot IDs from the selected Bill Of Ladings and will then recyle all Lot IDs added on the previous step. Any Lot ID that is not selected on this list will not be removed from the corresponding Bill of Lading/s and will not be recycled. Are you sure you want to continue?'}, :class=>"btn btn-danger" %>
</div>
<% end %>
我在这里做错了什么?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3