dimanche 28 juin 2015

jquery function executing multiple time for bootstrap modal

$(document).on('click', '.event_class', function() {

    $('#originalImageShow').modal('show');

    $('#originalImageShow').on('shown.bs.modal',  function() {
        alert('Modal Open');
    });
    $('#originalImageShow').on('hidden.bs.modal', function() {
        alert('Modal Close');
        $('#originalImageShow').off();
        $(this).removeData('bs.modal');
    });

});

Hi, Each time I click the event_class It shows "Modal Open" alert twice. Even sometimes it shows multiple times. And also when I close the Bootstrap Modal sometimes it shows "Modal Close" alert multiple times. Basically number of alert number is changing randomly. Please help.

Aucun commentaire:

Enregistrer un commentaire