I have a Collapse Dashboard loading page on my webpage. I need to execute the function after the transition is completed, and the panel is fully expanded. I found this example to access the callback when the panel is reset and added hidden.bs.collapse.
How to call the JavaScript function after the "Bootstrap: minimize plugin" transition is carried out .
But using similar code, I cannot start when the class is applied .collapse.in.
$('#collapseExample').on('.collapse.in', function(){
alert("hi");
});
I also found this code using promises to call a function after switching the class. It is supposed to wait until all animations are complete. jquery function on toggleClass complete? This does not work for my problem either.
So, I ask: How to call a function when executing a collapse function?
This snippet is trying to use the jQuery promise method. Ideally, it will add a class .redafter the panel has been expanded, but will start immediately.
http://www.bootply.com/Vx9oeyYy03#
$(document).on('click', '.btn', function(){
$('#collapseExample').collapse("toggle").promise().done(function () {
$('.well').addClass('red');
})
});
source
share