Rails 4 - link_to 在 Rails 中确认
Rails 4 - link_to with confirm in Rails
我正在尝试自定义我的对话框以确认 rails 中的 link_to 4。但我不明白他为什么骑 html 为 "confirm",并且应该是 "data-confirm"!
我试了很多方法,总是生成"confirm",像这样:
<%= link_to 'Delete', user, :method => :delete, :confirm => 'Are you sure?' %>
<a confirm="Are you sure?" rel="nofollow" data-method="delete" href="/user/13">Delete</a>
我遵循了这个教程:
http://thelazylog.com/custom-dialog-for-data-confirm-in-rails/
我在教程中使用了示例,但也不起作用
确认已在 rails 4.
中弃用
所以使用新语法:
<%= link_to "title", "#", data: {confirm: "Are you sure!"} %>
要在 rails 7 中获得相同的行为,您应该改用 turbo_confirm
键:
<%= link_to 'Delete', user,
data: {turbo_method: :delete, turbo_confirm: 'Are you sure?'} %>
我正在尝试自定义我的对话框以确认 rails 中的 link_to 4。但我不明白他为什么骑 html 为 "confirm",并且应该是 "data-confirm"!
我试了很多方法,总是生成"confirm",像这样:
<%= link_to 'Delete', user, :method => :delete, :confirm => 'Are you sure?' %>
<a confirm="Are you sure?" rel="nofollow" data-method="delete" href="/user/13">Delete</a>
我遵循了这个教程: http://thelazylog.com/custom-dialog-for-data-confirm-in-rails/ 我在教程中使用了示例,但也不起作用
确认已在 rails 4.
中弃用所以使用新语法:
<%= link_to "title", "#", data: {confirm: "Are you sure!"} %>
要在 rails 7 中获得相同的行为,您应该改用 turbo_confirm
键:
<%= link_to 'Delete', user,
data: {turbo_method: :delete, turbo_confirm: 'Are you sure?'} %>