I'm having trouble getting a collapsible bootstrap sidebar to display correctly in XPages. I found a simple example at bootstrapious.com, adapted the code for an XPage, and it almost works. The button to collapse the sidebar doesn't do anything. I am using Domino V12 and Designer V12, along with the built-in Bootstrap4 theme. The bootstrapious code includes its own .css file, along with some .css and .js for Font Awesome. I've tried removing those .css and .js files to check for conflicts. Obviously, they made the page look worse, but didn't help the collapse button to work. So I put them back in and below is the entire page. Is there some simple thing I've overlooked? It works fine in an HTML file, but not in XPages. One other interesting piece to the puzzle: If I start with a narrow browser window, the sidebar starts collapsed, but the button still won't expand it.
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.resources>
<xp:styleSheet href="/style2.css"></xp:styleSheet>
<xp:script
src="https://use.fontawesome.com/releases/v5.0.13/js/solid.js"
clientSide="true">
</xp:script>
<xp:script
src="https://use.fontawesome.com/releases/v5.0.13/js/fontawesome.js"
clientSide="true">
</xp:script>
</xp:this.resources>
<div class="wrapper">
<!-- Sidebar -->
<nav id="sidebar">
<div class="sidebar-header">
<h3>Bootstrap Sidebar</h3>
</div>
<ul class="list-unstyled components">
<p>Dummy Heading</p>
<li class="active">
<a href="#homeSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle">Home</a>
<ul class="collapse list-unstyled" id="homeSubmenu">
<li>
<a href="#">Home 1</a>
</li>
</ul>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a href="#pageSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle">Pages</a>
<ul class="collapse list-unstyled" id="pageSubmenu">
<li>
<a href="#">Page 1</a>
</li>
</ul>
</li>
<li>
<a href="#">Portfolio</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
<ul class="list-unstyled CTAs">
<li>
<a href="https://bootstrapious.com" target="_blank">bootsrapious</a>
</li>
</ul>
</nav>
<!-- Page Content -->
<div id="content">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button type="button" id="sidebarCollapse" class="btn btn-info">
<i class="fas fa-align-left"></i>
<span>Toggle Sidebar</span>
</button>
<button class="btn btn-dark d-inline-block d-lg-none ml-auto" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-align-justify"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Page</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page</a>
</li>
</ul>
</div>
</div>
</nav>
<h2>Collapsible Sidebar Using Bootstrap 4</h2>
<p>text</p>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#sidebar").mCustomScrollbar({
theme: "minimal"
});
$('#sidebarCollapse').on('click', function () {
$('#sidebar, #content').toggleClass('active');
$('.collapse.in').toggleClass('in');
$('a[aria-expanded=true]').attr('aria-expanded', 'false');
});
});
</script>
</xp:view>
CodePudding user response:
The JavaScript file popper.min.js uses AMD which conflicts with Dojo in XPages. See this answer for a solution on how to disable AMD in order to make it work: https://stackoverflow.com/a/30483034/785061