Skip to content

Instantly share code, notes, and snippets.

@shaneriley
Created September 1, 2010 18:39
Show Gist options
  • Save shaneriley/561136 to your computer and use it in GitHub Desktop.
Save shaneriley/561136 to your computer and use it in GitHub Desktop.
$("a[data-method='delete']").live("click.delete", function() {
var $e = $(this);
if ($e.attr("data-confirm")) {
if (!confirm($e.attr("data-confirm"))) {
return false;
}
}
var $form = $("<form />");
$("<input />").attr({
type: "hidden",
name: "_method",
value: "delete"
}).appendTo($form);
$form.bind("submit", function() {
$.ajax({
type: "POST",
url: $(this).attr("action"),
data: $(this).serialize()
});
return false;
}).submit();
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment