模态关闭时的基金会火灾事件?
Foundation fire event on modal close?
我在我的应用程序中使用 foundation reveals 通过 AJAX 发送信息。一切正常,但在模式关闭时我想更改一些文本。当使用 Foundation 6 关闭模态时,如何触发函数?任何帮助都会很棒,我当前的代码如下:
$("#share_modal").foundation('reveal', 'close', function() {
alert("closed");
});
我遇到了错误
Uncaught ReferenceError: We're sorry, 'reveal' is not an available method for this element.
但我指的元素是 .reveal
<div class="reveal" id="share_modal" data-reveal data-options="closeOnClick:true; closeOnEsc: true;">
<div class="row">
对于 Foundation 6,事件略有不同。
(function ($, window, undefined) {
'use strict';
$('[data-reveal]').on('closed.zf.reveal', function () {
var modal = $(this);
alert('closed');
});
$(document).foundation();
})(jQuery, this);
这将针对所有揭示。如果您只想定位 #share_modal ,请将选择器从 $('[data-reveal]')
更改为 $('#share_modal')
或者您可以使用 modal.id
检查元素 ID。可能是modal.attr('id')
参考:http://foundation.zurb.com/sites/docs/reveal.html#js-events
基础 5
$(document).on('close.fndtn.reveal', '[data-reveal]', function () {
alert('closed!!!');
});
我在我的应用程序中使用 foundation reveals 通过 AJAX 发送信息。一切正常,但在模式关闭时我想更改一些文本。当使用 Foundation 6 关闭模态时,如何触发函数?任何帮助都会很棒,我当前的代码如下:
$("#share_modal").foundation('reveal', 'close', function() {
alert("closed");
});
我遇到了错误
Uncaught ReferenceError: We're sorry, 'reveal' is not an available method for this element.
但我指的元素是 .reveal
<div class="reveal" id="share_modal" data-reveal data-options="closeOnClick:true; closeOnEsc: true;">
<div class="row">
对于 Foundation 6,事件略有不同。
(function ($, window, undefined) {
'use strict';
$('[data-reveal]').on('closed.zf.reveal', function () {
var modal = $(this);
alert('closed');
});
$(document).foundation();
})(jQuery, this);
这将针对所有揭示。如果您只想定位 #share_modal ,请将选择器从 $('[data-reveal]')
更改为 $('#share_modal')
或者您可以使用 modal.id
检查元素 ID。可能是modal.attr('id')
参考:http://foundation.zurb.com/sites/docs/reveal.html#js-events
基础 5
$(document).on('close.fndtn.reveal', '[data-reveal]', function () {
alert('closed!!!');
});