Kingsley Simon
Kingsley Simon

Reputation: 2210

modal 'show.bs.modal' event gets called before click event

So i have a modal in my code and it gets called like this

$('a.loan-application-view-toggle[data-toggle="modal"]').on('click', function() {
    $('#loan-application-view-modal').data('show-id', $(this).data('id'));
    $('#loan-application-view-modal').data('detailsID', $(this).data('assignmentid'));
});

But i also have this event in my javascript as well

$('#loan-application-view-modal').on('show.bs.modal', function (e) {

})

And after a while it overrides my click event

Upvotes: 0

Views: 89

Answers (1)

Prashant
Prashant

Reputation: 8040

This is expected behaviour. Bootstrap binds click handler on [data-toggle="modal"] element which triggers the show.bs.modal event. This handler is registered before yours and is therefore called before your click event handler.

Upvotes: 1

Related Questions