Created
March 16, 2011 13:22
-
-
Save henriquegogo/872478 to your computer and use it in GitHub Desktop.
Função delete do rails em jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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