I use bootstrap for a flask application and I want to keep sidebar menu collapsed after refreshing the page if a subclass of the sidebar is selected.
It partially works when adding "collapse show" at the div class just below this line "{% for Subclass in Class.subclasses() %}" but it shows all the subclasses of the entire sidebar. I need a solution to show the subclass of that specific class when is selected or active, not all of them.
Here is the code:
{% for Class in owlready2.Thing.subclasses() %}
<li class="active list-unstyled">
<a class="btn text-white d-inline-flex align-items-start rounded" href="{{ url_for("services", iri = Class.iri) }}" role="button" aria-expanded="true">{{ Class.name }}</a>
<button type="button" class="btn btn-warning dropdown-toggle dropdown-toggle-split" data-bs-toggle="collapse" data-bs-target="#{{ Class.name }}" aria-expanded="true">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
{% for Subclass in Class.subclasses() %}
<div class="collapse" id="{{ Class.name }}">
<ul class="list-unstyled">
<li><a href="{{ url_for("services", iri = Subclass.iri) }}" class="text-white d-inline-flex align-items-center rounded active" aria-current="true">{{ Subclass.name }}</a></li>
</ul>
</div>
{% endfor %}
</li>
{% endfor %}