所以我有三个link_to链接,每个链接都有一个数据确认属性,根据操作给出不同的警告。但它只显示第一个确认消息。
HTML输出
<li class="seller__email">
<a data-confirm="Are you sure you want to resend approval?" href="/admin/sales/2912/send_approval?sale_contract=23159&type=approval">
Resend Approval
</a>
<a data-confirm="Do you want to send an approval followup email to this seller?" href="/admin/sales/2912/send_approval?sale_contract=23159&type=approval_followup">
Send Followup (last contact: 4 days ago)
</a>
<a data-confirm="This will rebuild all sale items. Do you want to continue?" href="/admin/sales/2912/rebuild_remaining_sale_items?sale_contract=23159" id="rebuild_23159">
Rebuild Sale Items
</a>
</li>
Rails代码
<%= link_to send_approval_admin_sale_path(@sale, sale_contract: sale_contract.id, type: "approval"), data: { confirm: "Are you sure you want to resend approval?" } do %>
Resend Approval
<% end %>
<%= link_to send_approval_admin_sale_path(@sale, sale_contract: sale_contract.id, type: "approval_followup"), data: { confirm: "Do you want to send an approval followup email to this seller?" } do %>
Send Followup (last contact: <%= time_ago_in_words(sale_contract.approval_request_at) + ' ago' %>)
<% end %>
<%= link_to rebuild_remaining_sale_items_admin_sale_path(@sale, sale_contract: sale_contract.id), id: "rebuild_#{sale_contract.id}", data: { confirm: "This will rebuild all sale items. Do you want to continue?" } do %>
Rebuild Sale Items
<% end %>
当我点击任何项目时,我收到相同的确认消息,“您确定要重新发送批准吗?” (第一个确认消息)。