Skip to content

Instantly share code, notes, and snippets.

@henriquegogo
Created March 16, 2011 13:22
Show Gist options
  • Save henriquegogo/872478 to your computer and use it in GitHub Desktop.
Save henriquegogo/872478 to your computer and use it in GitHub Desktop.
Função delete do rails em jQuery
$('a[data-method="delete"]').click(function(event) {
csrf_param = $('meta[name=csrf-param]').attr('content');
csrf_token = $('meta[name=csrf-token]').attr('content');
if (confirm($(this).attr("data-confirm"))) {
var attr = {};
attr['_method'] = 'delete';
attr[csrf_param] = csrf_token;
$.post(this.href, attr, function() { location.reload(true) }, "script");
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment