【问题标题】:Foundation fire event on modal close?模式关闭时的基金会火灾事件?
【发布时间】:2017-03-23 14:00:27
【问题描述】:

我在我的应用程序中使用基础显示通过 AJAX 发送信息。一切正常,但在模式关闭时我想更改一些文本。当模态框以 Foundation 6 关闭时,如何触发函数?任何帮助都会很棒,我当前的代码如下:

$("#share_modal").foundation('reveal', 'close', function() {
    alert("closed");
});

我收到了错误

未捕获的 ReferenceError:很抱歉,“显示”不是此元素的可用方法。

但我指的元素是.reveal

<div class="reveal" id="share_modal" data-reveal data-options="closeOnClick:true; closeOnEsc: true;">
    <div class="row">

【问题讨论】:

    标签: javascript jquery zurb-foundation zurb-foundation-6


    【解决方案1】:

    在 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

    【讨论】:

      【解决方案2】:

      基础 5

      $(document).on('close.fndtn.reveal', '[data-reveal]', function () {
           alert('closed!!!');
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-09
        相关资源
        最近更新 更多