0

When I click to remove product from mini-cart a confirm dialog pops up with "Cancel" or "Ok", if I click on "Cancel" the product still gets removed.

Any idea why and how to fix it?

This is the a element to remove product from mini-cart:

<a href="long_delete_url_here" title="Remove This Item" onclick="return confirm('Are you sure you would like to remove this item from the shopping cart?');" class="btn-remove">Remove This Item</a> 

No errors in console, tried adding custom jquery function, adding preventDefault, but nothing. Even just adding onclick="return false;" doesn't do anything.

I did a small test and added onclick="return false;" to different elements like buttons and links in different templates, but the buttons and links still work after clicking on them. Any idea what could be wrong?

Magento 1.9.0.1

3
  • Are you using the default magento mini cart or some other ajax mini cart.? Commented Jun 28, 2017 at 13:17
  • @AthulVijayan default. Commented Jun 28, 2017 at 14:44
  • @AthulVijayan I did a small test and added onclick="return false;" to different elements like buttons and links in different templates, but the buttons and links still work after clicking on them. Any idea what could be wrong? Commented Jun 28, 2017 at 14:52

1 Answer 1

2

Try this

 <a href="http://www.google.com" title="Remove This Item" onclick="productcartremove(event);" class="btn-remove">Remove This Item</a> <script> function productcartremove(event,url) { var r = confirm("Are you sure you would like to remove this item from the shopping cart?"); if (r == true) { return true; } else{ event.preventDefault(); } } </script> 
2
  • It still removes the product (the link fires anyway). Commented Jun 29, 2017 at 12:22
  • This is working fine on my magento instance. Commented Jun 30, 2017 at 9:01

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.