NullVoxPopuli
NullVoxPopuli

Reputation: 65103

Ruby on Rails: How do I add a confirmation to a submit_tag

<%= submit_tag "Delete" , :confirm => 'Are you sure you want to delete the selected?' %>

doesn't work.

how do I do this?

Upvotes: 2

Views: 3041

Answers (3)

Ketan Mangukiya
Ketan Mangukiya

Reputation: 418

I found this solution and it works to me.

<%= submit_tag 'Save', onclick: "return confirm('Are you sure?')" %>

The Solution link is Here

Thanks

Upvotes: 3

BigJim
BigJim

Reputation: 51

Try this :

<%= submit_tag "Delete", data: { confirm: 'Are you sure you want to delete the selected?' }%>

Upvotes: 5

Slobodan Kovacevic
Slobodan Kovacevic

Reputation: 6888

It should work. Most likely you didn't include necessary JavaScript files. Do you have something like this in your HTML head tag?

<%= javascript_include_tag :defaults %>

Upvotes: 1

Related Questions