Reputation: 2644
I want to use javascript to close an offcanvas area as the result of loading an ajax script.
The documentation says $('#element').foundation('close', cb);
but there isn't much in the way of explanation as to what #element
and cb
are :/
What are #element
and cb
? How would you programmatically close their example?
<body>
<div class="off-canvas-wrapper">
<div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
<div class="off-canvas position-left" id="offCanvas" data-off-canvas>
<!-- Close button -->
<button class="close-button" aria-label="Close menu" type="button" data-close>
<span aria-hidden="true">×</span>
</button>
<!-- Menu -->
<ul class="vertical menu">
<li><a href="#">Foundation</a></li>
<li><a href="#">Dot</a></li>
<li><a href="#">ZURB</a></li>
<li><a href="#">Com</a></li>
<li><a href="#">Slash</a></li>
<li><a href="#">Sites</a></li>
</ul>
</div>
<div class="off-canvas-content" data-off-canvas-content>
<!-- Page content -->
</div>
</div>
</div>
</body>
Upvotes: 0
Views: 727
Reputation: 775
You can use trigger close button.
<button id="btn-close-offcanvas" type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
$("#btn-close-offcanvas").click();
Upvotes: 0
Reputation: 127
you can do this in js with $('#offCanvas').foundation('close');
Upvotes: 1