简体   繁体   中英

Ruby on Rails: Why the confirmation message does not appear in “link_to('delete', …)”?

I have the following link next to one of my products:

<%= link_to("Delete", {:action => 'destroy', :id => product.id}, :class => 'action', :confirm => 'Are you sure?') %>

but when I click it, the confirmation box does not appear.

The generated HTML is:

<a data-confirm="Are you sure ?" class="action" href="/products/destroy/48">Delete</a>

Please advise.

<%= link_to("Delete", product, :method => :delete, :class => 'action', :confirm => 'Are you sure?') %>

检查你的javascript_include_tag ,它应该工作正常:)

try adding it as a data-attribute

data: { confirm: "Are you sure?" }

Ensure rails.js is being loaded on the page. The easiest way to accomplish this is with:

javascript_include_tag :defaults

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM