Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added confirm() to delete client-side code

commit f66fdb5c3bebdf693f62884ffc06a40b93328bb5 1 parent 50ec367
Alex Young authored November 22, 2010

Showing 1 changed file with 18 additions and 16 deletions. Show diff stats Hide diff stats

  1. 34  public/javascripts/application.js
34  public/javascripts/application.js
... ...
@@ -1,21 +1,23 @@
1 1
 (function() {
2 2
   $('.destroy').live('click', function(e) {
3  
-    var element = $(this),
4  
-        form = $('<form></form>');
5 3
     e.preventDefault();
6  
-    form
7  
-      .attr({
8  
-        method: 'POST',
9  
-        action: element.attr('href')
10  
-      })
11  
-      .hide()
12  
-      .append('<input type="hidden" />')
13  
-      .find('input')
14  
-      .attr({
15  
-        'name': '_method',
16  
-        'value': 'delete'
17  
-      })
18  
-      .end()
19  
-      .submit();
  4
+    if (confirm('Are you sure you want to delete that item?')) {
  5
+      var element = $(this),
  6
+          form = $('<form></form>');
  7
+      form
  8
+        .attr({
  9
+          method: 'POST',
  10
+          action: element.attr('href')
  11
+        })
  12
+        .hide()
  13
+        .append('<input type="hidden" />')
  14
+        .find('input')
  15
+        .attr({
  16
+          'name': '_method',
  17
+          'value': 'delete'
  18
+        })
  19
+        .end()
  20
+        .submit();
  21
+    }
20 22
   });
21 23
 })();

0 notes on commit f66fdb5

Please sign in to comment.
Something went wrong with that request. Please try again.