I’ve hit a couple stumbling blocks building a dash app with Bootstrap styling.
I’ve wanted to use certain interactive elements (specifically collapsible and nav-bar) which typically require small bits of java script to enable the interactive behavior. For example:
Something like:
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
Would need a javascript piece like:
$(".nav a").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).addClass("active");
});
I’ve been able to hack together ways of supporting this behavior in my python code, but they tend to be a lot clunkier then just including the JS snippet. I’ve tried hosting a static JS file (How do I use Dash to add local css?), but since the JS runs before dash renders the page the callbacks don’t get registered without additional hacking.
It seems like the html.Script component might fix this, but that currently has issues as well https://github.com/plotly/dash/issues/93 . Anyone figure out a good way to support these sorts of components? Otherwise it seems like fixing the Script component would make this a much easier to solve issue.