Reputation: 11615
I want to give a list of items I'm iterating over the ability to collapse and uncollapse again when pressing a hide button.
Pretty easy to do using bootsraps collapse
class and setting up the appropriate anchor link / id references.
However, the first time I click the button it will collapse and then unhide the element again. Because I haven't set the initial collapse class (because I want it to show by default). After this everything runs smoothly it's just the first click that doesn't work properly.
How would I go about preventing this default behavior?
I know I could switch out the bootstrap class for a button / jQuery using the collapse class just seems to be a better way to integrate the feature.
Edit: updated bootply for non-working vs working first click
Upvotes: 0
Views: 124
Reputation: 2551
The element you want to be initially visible still needs the collapse
class. To show it by default just add the in
class as well. Updated your bootply here with an example
Upvotes: 2