Permalink
Browse files

Added confirm() to delete client-side code

  • Loading branch information...
Alex Young
Alex Young committed Nov 22, 2010
1 parent 50ec367 commit f66fdb5c3bebdf693f62884ffc06a40b93328bb5
Showing with 18 additions and 16 deletions.
  1. +18 −16 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();
}
});
})();

0 comments on commit f66fdb5

Please sign in to comment.