On zurb foundation's website at http://foundation.zurb.com/docs/reveal.php they listed some Options including
open: callback function that triggers 'before' the modal opens.
opened: callback function that triggers 'after' the modal is opened.
close: callback function that triggers 'before' the modal prepares to close.
closed: callback function that triggers 'after' the modal is closed.
But I have no idea how to use them with my modal. Itried
$('#myModal').closed(function()
{});
$('#myModal').trigger('reveal:closed')(
{});
$('#myModal').reveal.closed(function()
{});
$('#myModal').reveal().closed(function()
{});
I have googled but found no hits. Anyone who can explain it or give me an example or provide a related link?
Thank you! It works!
I have yet another closely related question for reveal()
<a href="#" class="button" data-reveal-id="myModal2">Click Me For A Modal</a>);
I tried to add one attribute like data-closeOnBackgroundClick="false"
That doen't seem to work. What should be the correct syntax? Will it work for callback function as well?
Call
reveal
like you normally would, but include the name of the option and corresponding function as an object:The foundation 5 documentation specifies scoping of reveal events to the 'reveal' eventspace. However, the actual modal events do not seem to fire consistently within this eventspace. Removing this specification fixes the issue:
In foundation 3.2.5 you should bind 'reveal:opened' like this:
Regards, MarianoC.
On Zurb Foundation v6, these events were renamed to
xxx.zf.reveal
:Source: http://foundation.zurb.com/sites/docs/reveal.html#js-events
Examples:
Generic callback that will fire for all modals:
Callback that will fire when a specific modal is opened:
Event Bindings for Zurb Foundation Reveal -
There are a series of events that you can bind to for triggering callbacks:
If you have multiple data-reveal used in single page as follows :
Then in this situations you can trigger callback same as explained above but with little modification as shown below :
Looking at Foundation 5 and found that the reveal library triggers open, opened, close, and closed events. Just attach a handler to the event you want.
$('#myModal').on([event], handler)
You can also pass the handlers via the settings argument. Check this out: https://github.com/zurb/foundation/blob/master/js/foundation/foundation.reveal.js#L92