[英]Foundation fire event on modal close?
我在我的应用程序中使用基础显示通过AJAX发送信息。 一切正常,但在模态结束时我想改变一些文字。 当模态与Foundation 6关闭时,如何触发函数? 任何帮助都会很棒,我目前的代码如下:
$("#share_modal").foundation('reveal', 'close', function() {
alert("closed");
});
我收到了错误
未捕获的ReferenceError:很抱歉,'reveal'不是此元素的可用方法。
但我所指的元素是.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!!!');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.