mardi 4 août 2015

How to make a confirmation modal with Remodal

I use Remodal ( http://ift.tt/1ImlYRr ) to make some modals, normally I use only the alert modal but now I want to use a confirmation modal.

I have made a delete button with a confirmation modal, I have the following code:

$('#delete_button').click(function() {
    $('[data-remodal-id = modal-delete]').remodal().open();
    $(document).on('confirmation', '#modal-delete', function () {
        alert('Confirmation button is clicked');
    });
    $(document).on('cancellation', '#modal-delete', function () {
        alert('Cancel button is clicked');
    });
});

<div class="remodal" data-remodal-id="modal-delete">
    <div class="h1_modal">Delete confirmation</div> 
    <div class="p_modal">Are you sure?</div>
    <button data-remodal-action="cancel" class="remodal-cancel">Cancel</button>
    <button data-remodal-action="confirm" class="remodal-confirm">OK</button>
</div>

The modal is opening when I click on the button with the ID #delete_button but when I choose Cancel or OK, I don't see any alert.

How can I get this working?

Kind regards,

Arie

Aucun commentaire:

Enregistrer un commentaire