Thanks for replying…
I didn’t “copy paste” the offcanvas. The offcanvas work well is just like I want a script to control it when offcanvas2 is active, Offcanvas1 should open on top of it when is called…
In other words, it should open simultaneously when offcanvas2 is active…
Let me explain:
The offcanvas2 contains data that needs to be visible unless the user hides it using the close btn.(Displays at the bottom)
But when I open offcanvas1 which contains my page navigations, it hides offcanvas2 which is what I don’t want it to.
So I need a script that first check if offcanvas2 is active when offcanvas1 is being toggled, and if active should not hide it but open on top of it(simultaneously).
document.addEventListener('DOMContentLoaded', function() {
var offcanvas1 = document.getElementById('offcanvas1');
var offcanvas2 = document.getElementById('offcanvas2');
offcanvas1.addEventListener('hidden.bs.offcanvas', function () {
var offcanvas2Instance = new bootstrap.Offcanvas(offcanvas2);
if (offcanvas2.classList.contains('show')) {
offcanvas2Instance.show();
}
});
offcanvas2.addEventListener('hidden.bs.offcanvas', function () {
var offcanvas1Instance = new bootstrap.Offcanvas(offcanvas1);
if (offcanvas1.classList.contains('show')) {
offcanvas1Instance.show();
}
});
offcanvas1.addEventListener('show.bs.offcanvas', function () {
var offcanvas2Instance = new bootstrap.Offcanvas(offcanvas2);
if (offcanvas2.classList.contains('show')) {
offcanvas2Instance.show();
}
});
});
@ben, @famousmag, I have tried but still getting the same results. @ben, somehow its will behave as if its working and then it closes again in a second.
Below is a video of what I want to achieve:
The offcanvas displayed at the bottom is what I don’t want it to be closed when the one on the left is open.
OK its actually not a collapse. Its a button that toggles the offcanvas on the left. It looks like a navbar collapse toggler because of the font awesome icon class used but it’s just a button.