TomDogg
TomDogg

Reputation: 3937

Rails 3: submit_tag does not :confirm (while link_to does)

Why does this correctly launch the "confirm" dialog...

<%= link_to "Visit Other Site", "http://www.rubyonrails.org/", :confirm => "Are you sure?" %>

...but not this one:

<%= submit_tag "Save", :confirm => "Are you sure?" %>

I'm using:

Upvotes: 1

Views: 1971

Answers (2)

TomDogg
TomDogg

Reputation: 3937

It's a pending issue/bug, see comments above.

Upvotes: 0

Simone Carletti
Simone Carletti

Reputation: 176392

The :confirm option is deprecated, it is now going to be replaced by the data attribute. Internally, the submit_tag is already doing the replacement.

See the submit_tag documentation and source code.

Because the data attributes rely on Unobtrusive JavaScript to be executed, you should have included jQuery JS and the Rails UJS file. Otherwise, the attribute will be visible in the source code (please check it) but will not trigger the confirmation.

Upvotes: 1

Related Questions