如何使用 Zurb Foundation 显示打开、打开、关闭、关闭回调函数?

在 zurb 基金会的网站 http://foundation.zurb.com/docs/reveal.php 他们列出了一些选项,包括

On zurb foundation's website at http://foundation.zurb.com/docs/reveal.php they listed some Options including

open:在模式打开之前触发的回调函数.

open: callback function that triggers 'before' the modal opens.

opened:在模态打开后触发的回调函数.

opened: callback function that triggers 'after' the modal is opened.

close:在模式准备关闭之前触发回调函数.

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. I tried:

$('#myModal').closed(function()
{});

$('#myModal').trigger('reveal:closed')(
{});

$('#myModal').reveal.closed(function()
{});

$('#myModal').reveal().closed(function()
{});

我在 Google 上搜索过,但没有找到任何匹配结果.任何人都可以解释它或给我一个例子或提供相关链接?

I have Googled but found no hits. Anyone who can explain it or give me an example or provide a related link?

但是,给出的建议有效对于 reveal(),我还有另一个密切相关的问题:

The suggestion given works, however I have yet another closely related question for reveal():

<a href="#" class="button" data-reveal-id="myModal2">Click Me For A Modal</a>);

我尝试添加一个属性,例如 data-closeOnBackgroundClick="false" 这似乎不起作用.正确的语法应该是什么?它也适用于回调函数吗?

I tried to add one attribute like data-closeOnBackgroundClick="false" That doesn't seem to work. What should be the correct syntax? Will it work for callback function as well?

推荐答案

像往常一样调用 reveal,但将选项名称和对应函数作为对象包含:

Call reveal like you normally would, but include the name of the option and corresponding function as an object:

//Reveal the modal and say "Good bye" when it closes
$("#myModal").reveal({ "closed": function () { alert("Good bye") } });

相关文章