jazzis18
jazzis18

Reputation: 213

rails - link_to :confirm not generates data-confirm

I'm using Rails 4.1.6 and Ruby 2.1.4. I have a link_to:

= link_to 'Delete comment', [@post, comment], :method => :delete, :confirm => "Are you sure?"

It generates a HTML:

<a confirm="Are you sure?" data-method="delete" href="/posts/first-post/comments/26" rel="nofollow">Delete comment</a>

Why it generates confirm rather than data-confirm?

My application.js includes:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .

My layouts/application.html.erb includes:

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>

Upvotes: 0

Views: 1029

Answers (1)

You didn't specified it. Try this instead

= link_to 'Delete comment', [@post, comment], :method => :delete, :data => { :confirm => "Are you sure?" }

Upvotes: 2

Related Questions