I'm looking for a simple way to confirm a delete of an item (I'm using Laravel 5.3)
I have this code:
<a href="{{url('/deleteProduct')}}<?='/'.$product->id;?>"><span class="glyphicon glyphicon-trash"></span></a>
So when clicking on the link, I call the route deleteProduct/{id}
. But what I want is, that when clicking on the link, there is a prompt, saying something like sure to delete? yes/no. Only when clicking yes, this route is called then.
I tried it with a bootstrap modal and in general it worked, but I had problems with the $product
, actually $product is an item in a foreach, so around the <a>
-tag, there is a @foreach($products as $product)
. That's why the modal didn't work, because it got somehow messed up with this foreach (actually $product always held the last "product", because i defined it after the foreach).
Is there a easy to achieve what I want? Alternatively I could create a modal for every product, but there could be up to thousands of those, so this would be nonsense. So whats the better way?
Edit: The normal javascript function confirm()
would work, but thats a little "too basic", so I want something that fits in the design, so something with bootstrap would be nice, or anything thats not a alert dialog with two buttons. The functionality of confirm
is the one that I want. But also, confirm
provides the buttons in english, I may want to customize those to be used in more then one language.