【问题标题】:Pass data to afterClose将数据传递给 afterClose
【发布时间】:2019-07-03 09:43:41
【问题描述】:

我正在使用 FancyBox 3,我需要将数据传递给 afterClose 并在关闭 Iframe 后触发此数据。

<a data-fancybox data-type="iframe"
                       data-src="{{route('tbl_properties.getApartmentsForLegal3',[$property->id,$group_id])}}"
                       href="javascript:;" type="button" class="btn btn-info " title="Show Apartments" data-reference="{{$property->property_reference}}">
                        <i class="nav-icon  i-Home-Window fa-4x "></i>
                    </a>

jquery:

    $('[data-fancybox]').fancybox({
        property_reference :$(this).data('reference'),


        iframe: {
            preload: false
        },
        fullScreen: {
            autoStart: true
        },
        afterClose: function(instance, slide ,property_reference)  {

            alert(property_reference);
           window.location.reload();



        }
    });

数据是property_reference。

谢谢

【问题讨论】:

    标签: fancybox-3


    【解决方案1】:

    current.opts.$orig 将引用当前触发元素(例如,您的链接),您可以使用它来检索自定义数据,例如:

    $('[data-fancybox]').fancybox({
      iframe: {
        preload: false
      },
      fullScreen: {
        autoStart: true
      },
      afterClose: function(instance, current)  {
    
        alert(current.opts.$orig.data('reference'));
    
      }
    });
    

    演示 - https://codepen.io/anon/pen/bPKVpB?editors=1010

    【讨论】:

      猜你喜欢
      • 2015-07-27
      • 2015-11-16
      • 2015-09-23
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多