0

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">&times;</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>
Tim Morton
  • 2,614
  • 1
  • 15
  • 23

2 Answers2

1

you can do this in js with $('#offCanvas').foundation('close');

guy banlock
  • 107
  • 2
  • 4
0

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();
Ergin Çelik
  • 719
  • 7
  • 14