Laravel Delete Link with jQuery
$(document).ready(function($) { | |
$('a[data-delete]').on('click', function(evt) { | |
evt.preventDefault(); | |
var form_id='delete_'+Math.floor((Math.random() *1000) +1); | |
if(confirm('Are you sure?')) { | |
$(this).after(function() { | |
form='<form id="'+form_id+'" action="'+$(this).data('delete') +'" method="post">'; | |
form+='<input type="hidden" name="_token" value="'+$('meta[name="csrf-token"]').attr('content') +'">'; | |
form+='<input type="hidden" name="_method" value="DELETE">'; | |
form+='</form>' | |
return form; | |
}); | |
$('#'+form_id).submit(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment