[英]Foundation fire event on modal close?
I'm using foundation reveals within my application to send information via AJAX. 我在我的应用程序中使用基础显示通过AJAX发送信息。 Everything is working but upon the modal closing I want to change some text.
一切正常,但在模态结束时我想改变一些文字。 How do you fire a function when a modal closes with Foundation 6?
当模态与Foundation 6关闭时,如何触发函数? Any help would be great, my current code is as follows:
任何帮助都会很棒,我目前的代码如下:
$("#share_modal").foundation('reveal', 'close', function() {
alert("closed");
});
I'm getting the error 我收到了错误
Uncaught ReferenceError: We're sorry, 'reveal' is not an available method for this element.
未捕获的ReferenceError:很抱歉,'reveal'不是此元素的可用方法。
But the element I'm referring to is the .reveal
但我所指的元素是
.reveal
<div class="reveal" id="share_modal" data-reveal data-options="closeOnClick:true; closeOnEsc: true;">
<div class="row">
With Foundation 6, the events are a little different. 在Foundation 6中,活动有点不同。
(function ($, window, undefined) {
'use strict';
$('[data-reveal]').on('closed.zf.reveal', function () {
var modal = $(this);
alert('closed');
});
$(document).foundation();
})(jQuery, this);
That will target all reveals. 这将针对所有的揭示。 If you want to target just #share_modal change the selector from
$('[data-reveal]')
to $('#share_modal')
or you can use modal.id
to check the element id. 如果您只想定位#share_modal,请将选择器从
$('[data-reveal]')
更改$('#share_modal')
或者您可以使用modal.id
检查元素ID。 It may be modal.attr('id')
它可能是
modal.attr('id')
Reference: http://foundation.zurb.com/sites/docs/reveal.html#js-events 参考: http : //foundation.zurb.com/sites/docs/reveal.html#js-events
Foundation 5 基金会5
$(document).on('close.fndtn.reveal', '[data-reveal]', function () {
alert('closed!!!');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.