Rails 3 Confirm Delete - in IE8, pressing Cancel still deletes
Following Michael Hartl's tutorial. Using Rails 3.0.9 under Ubuntu. The following header is in application.html.erb:
<head>
<title><%= title %></title>
<%= csrf_meta_tag %>
<%= render 'layouts/stylesheets' %>
<%= javascript_include_tag :defaults %>
</head>
No jQuery. Tutorial Listing 10.38 specifies the Delete action be called as follows:
<%= link_to "delete", user, :method => :delete, :confirm => "You sure?",
:title => "Delete #{user.name}" %>
Here is an example of the generated HTML:
<a href="/users/13" data-confirm="You sure?" data-method="delete"
rel="nofollow" title="Delete Mylene Gaylord">delete</a>
I've tested the confirmation under three browsers:
- Firefox 3 under Ubuntu: "OK" deletes user, "Cancel" does not (good)
- Firefox 5 under Win7: "OK" deletes user, "Cancel" does not (good)
- IE8 under Win7: both "OK" and "Cancel" delete user (bad!)
When using IE8, why is Cancel calling the Delete code, and how do I fix it? Is there a way to test that Cancel does, in fact, cancel the action, no matter what browser is used?
Updat开发者_Go百科e 9/29/2011: after upgrading to Rails 3.1 and converting from Prototype to jQuery (Tutorial section 13.1.4), IE8 behaves properly: pressing Cancel aborts the delete action. However that doesn't answer the original question of why IE8 can't Cancel the delete from Rails 3.0.9 with Prototype.
Make sure you include this in you head.
app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<%= csrf_meta_tag %>
</head>
<body>
HtML
</body>
</html>
精彩评论