Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a function when bootstrap collapse expands

I want to activate this javascript:

jsPlumb.repaintEverything();

...and fire up an alert box saying "I'm expanding!!!" when a user clicks the button in this fiddle

Does anyone know how to achieve this?

like image 353
Drostan Avatar asked Jan 24 '26 05:01

Drostan


1 Answers

You can use the shown.bs.collapse event that Bootstrap raises:

$('#demo').on('shown.bs.collapse', function() {
    jsPlumb.repaintEverything();
});

Updated fiddle

Note that this event fires after the element expansion animation has completed. If you want to run the code as the animation starts, use show.bs.collapse instead

like image 195
Rory McCrossan Avatar answered Jan 26 '26 18:01

Rory McCrossan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!