We are alerting a message after close of popups. This was working fine with foundation 4 and now i am trying to upgrade to foundation 6 and it fails to trigger event followed by close of popup.
Foundation 4 (working prototype):
$(document).ready(function() {
$(document).foundation();
$('#reveal_trigger').on("click", function() {
$('#reveal_modal').foundation("reveal","open");
})
$('#close_trigger').on("click", function() {
$('#reveal_modal').foundation("reveal","close").one('closed', function ()
{
alert("closed");
});
});
})
<!doctype html>
<head>
<meta charset = "utf-8" />
<meta http-equiv = "x-ua-compatible" content = "ie=edge" />
<meta name = "viewport" content = "width = device-width, initial-scale = 1.0" />
<title>Reveal Basics</title>
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/4.2.3/css/foundation.css">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/4.2.3/js/vendor/jquery.min.js"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/4.2.3/js/foundation.min.js"></script>
</head>
<body>
<h2>Reveal Basics Example</h2>
<!--<p><a data-reveal-id="reveal_modal">Click Me For A Modal</a></p>-->
<p><a id="reveal_trigger">Click Me For A Modal</a></p>
<div class="reveal-modal" id="reveal_modal" data-reveal>
<h2>Foundation 4</h2>
<p>Foundation is a family of responsive front-end frameworks that make
it easy to design beautiful responsive websites, apps and emails
that look amazing on any device!
<a id="close_trigger">Click to close</a>
</p>
<button type="button" class="close-reveal-modal" aria-label="Close reveal">
<span aria-hidden="true">×</span>
</button>
</div>
</body>
</html>
Foundation 6 (Failing prototype):
$(document).ready(function() {
$(document).foundation();
$('#reveal_trigger').on("click", function() {
$('#reveal_modal').foundation("open");
});
$('#close_trigger').on("click", function() {
$('#reveal_modal').foundation("close").one('closed', function ()
{
alert('closed');
});
});
})
<!doctype html>
<head>
<meta charset = "utf-8" />
<meta http-equiv = "x-ua-compatible" content = "ie=edge" />
<meta name = "viewport" content = "width = device-width, initial-scale = 1.0" />
<title>Reveal Basics</title>
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/motion-ui/1.1.1/motion-ui.css">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></script>
</head>
<body>
<h2>Reveal Basics Example</h2>
<!--<p><a data-open="reveal_modal">Click Me For A Modal</a></p> -->
<p><a id="reveal_trigger">Click Me For A Modal</a></p>
<div class="reveal" id="reveal_modal" data-reveal data-animation-in="slide-in-down" data-animation-out="slide-out-up">
<h2>Foundation 6</h2>
<p>Foundation is a family of responsive front-end frameworks that make
it easy to design beautiful responsive websites, apps and emails
that look amazing on any device.
<a id="close_trigger">Click to close</a>
</p>
<button type="button" class="close-button" aria-label="Close reveal" data-close>
<span aria-hidden="true">×</span>
</button>
</div>
</body>
</html>
Same code with foundation 6 fails to trigger event after close.
The events have changed. Upgrading from 4 to 6 are two major breaking versions.
It is now
open.zf.revealandclosed.zf.reveal, see https://foundation.zurb.com/sites/docs/reveal.html#js-eventsThe method is
.foundation('close'), see https://foundation.zurb.com/sites/docs/reveal.html#closeGenerally speaking you should use Foundation 6.5 / latest. The docs are for this version, not 6.0. And many things have changed, including breaking changes in 6.x.