JuliaCesar JuliaCesar - 3 months ago 17
Javascript Question

Twitter Bootstrap: Accordion plugin collides with Modal

I was faced with a problem when using an accordion in the pop-up modal (all are Twitter Bootstrap plugins).
Modal has closed whenever any accordion block was toggled.

Answer

Accordion collapse fires a 'hidden' event, which is actual for Modal plugin too. So, there is a way to prevent modal closing:

$(document).on('click', 'a.accordion-toggle', function(e) {
    $(e.target).parent().siblings('.accordion-body').on('hidden', function(e) {
        e.stopPropagation();
    });
});

Hope hat helps you.