Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added confirm() to delete client-side code

  • Loading branch information...
commit f66fdb5c3bebdf693f62884ffc06a40b93328bb5 1 parent 50ec367
Alex Young authored
Showing with 18 additions and 16 deletions.
  1. +18 −16 public/javascripts/application.js
View
34 public/javascripts/application.js
@@ -1,21 +1,23 @@
(function() {
$('.destroy').live('click', function(e) {
- var element = $(this),
- form = $('<form></form>');
e.preventDefault();
- form
- .attr({
- method: 'POST',
- action: element.attr('href')
- })
- .hide()
- .append('<input type="hidden" />')
- .find('input')
- .attr({
- 'name': '_method',
- 'value': 'delete'
- })
- .end()
- .submit();
+ if (confirm('Are you sure you want to delete that item?')) {
+ var element = $(this),
+ form = $('<form></form>');
+ form
+ .attr({
+ method: 'POST',
+ action: element.attr('href')
+ })
+ .hide()
+ .append('<input type="hidden" />')
+ .find('input')
+ .attr({
+ 'name': '_method',
+ 'value': 'delete'
+ })
+ .end()
+ .submit();
+ }
});
})();
Please sign in to comment.
Something went wrong with that request. Please try again.