Skip to content

Instantly share code, notes, and snippets.

Last active October 11, 2018 16:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Laravel Delete Link with jQuery
<a href="#" data-delete="{{ route('account.bots.pages.destroy', ['bot_id' => $bot->id, 'id' => $page->id]) }}" class="text-danger">
$(document).ready(function($) {
$('a[data-delete]').on('click', function(evt) {
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">';
return form;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment