link 不要求使用 :confirm 进行确认
link doesn't ask for confirmation with :confirm
我正在尝试设置一个 link 来删除数据库条目,一切都按预期进行,只是不首先要求确认。我想我做的一切都正确,我正在 ubuntu.
上的 firefox 中对此进行测试
<%= link_to "Delete", @post, :confirm => "Are you sure you want to delete?", :method => :delete %>
感谢任何帮助。
Read the documentation carefully
:
:data
- This option can be used to add custom data attributes.
数据属性
confirm: 'question?'
- This will allow the unobtrusive JavaScript driver to prompt with the question specified (in this case, the
resulting text would be question?. If the user accepts, the link is
processed normally, otherwise no action is taken.
你的link_to
应该是这样的:
<%= link_to "Delete", @post, data: { :confirm => "Question?", :method => :delete } %>
你的 application.js 文件中有这几行吗?
//= require jquery
//= require jquery_ujs
我正在尝试设置一个 link 来删除数据库条目,一切都按预期进行,只是不首先要求确认。我想我做的一切都正确,我正在 ubuntu.
上的 firefox 中对此进行测试<%= link_to "Delete", @post, :confirm => "Are you sure you want to delete?", :method => :delete %>
感谢任何帮助。
Read the documentation carefully
:
:data
- This option can be used to add custom data attributes.
数据属性
confirm: 'question?'
- This will allow the unobtrusive JavaScript driver to prompt with the question specified (in this case, the resulting text would be question?. If the user accepts, the link is processed normally, otherwise no action is taken.
你的link_to
应该是这样的:
<%= link_to "Delete", @post, data: { :confirm => "Question?", :method => :delete } %>
你的 application.js 文件中有这几行吗?
//= require jquery
//= require jquery_ujs