As current browsers do not implement DELETE verb Laravel simulates it via hidden fields. You have to do it with help of Form like this:
{{ Form::open(array('route' => array('accounts.destroy', $accountID), 'method' => 'delete')) }}
<button type="submit" >Delete Account</button>
{{ Form::close() }}
More details explained here: http://stackoverflow.com/questions/19643483/crud-laravel-4-how-to-link-to-destroy
Thanks for the quick help! Worked like a charm :)
For those who don't want to use forms but javascript... Apparently, as i just found out, jQuery does the trick, too...
function checkDelete(id) {
if (confirm('Really delete?')) {
$.ajax({
type: "DELETE",
url: '/<resource>/' + id,
success: function(result) {
// do something
}
});
}
}
<a href="javascript:checkDelete(1);">...</a>
The advantage of this approach is that you can cancel it because of the confirmation box.
Cheers
You can also just the unobtrusive jquery adapter: https://github.com/rails/jquery-ujs That looks for data attributes, for methods (post/put/delete), confirm popups or send as ajax, without any additional javascript.
<a href="{{ route('accounts.destroy',array($accountID)) }}" data-method="delete" rel="nofollow" data-confirm="Are you sure you want to delete this?">Delete this entry</a>
You can also just the unobtrusive jquery adapter: https://github.com/rails/jquery-ujs That looks for data attributes, for methods (post/put/delete), confirm popups or send as ajax, without any additional javascript.
I come across:
TokenMismatchException
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community