Search code examples
jqueryhrefalertconfirm

jquery-confirm - How to send href link to browser


I'm using this nice plugin jquery-confirm v3.0.3 (http://craftpip.github.io/jquery-confirm/) to confirm actions

But when using the code below, the href action from my link is not executed when i press the OK button ?

What i'm doing wrong ? Thanks for your help...

<a class="delItem" href="?del=true&id=1">Supprimer</a>

$('a.delItem').confirm({
            title: 'Confirmer cette action',
            content: '',
            animation: 'left',
            theme: 'light',
            type: 'red',
            autoClose: 'cancel|10000',
            buttons: {
                confirm: {
                    text: 'OK'
                },
                cancel: {
                    text: 'Annuler',
                    action: function () {
                    //$.alert('action is canceled');
                    }
                }
            }
        });

Solution

  • Just add action function inside confirm block (like on cancel) and inside that:

    window.location.href = $(this).attr("href");