jQuery lightbox(featherlight)如何运行beforeOpen和afterOpen事件

Mr.*_*ppy 2 javascript jquery lightbox featherlight.js

我正在使用这个jQuery灯箱,这是一个羽毛灯,并不明白如何发射波纹管事件,因为我不好,所以我跳了一些人的帮助:

开放前:

beforeOpen: function(event){

}
Run Code Online (Sandbox Code Playgroud)

打开后:

afterOpen: function(event){

}
Run Code Online (Sandbox Code Playgroud)


我的代码工作:

<button id="openbox" href="#fl1">Load Lightbox on click event</button>

<div class="lightbox" id="fl1">
    <h2>Delete Item</h2>
    <div class="row">
        <div class="twelve columns">
            <strong>Are you Sure?</strong>
            <br>blubblub?
        </div>
    </div>
    <div class="right"> <a href="#" class="btn btn_gray no text_none" id="close_button">Close</a>
    <a href="#" class="btn btn_red text_none">Yes</a>
    </div>
</div>


$('#openbox').click(function() {
    $.featherlight('#fl1');
});
Run Code Online (Sandbox Code Playgroud)

我的小提琴:http://jsfiddle.net/g68bZ/29/

谢谢.

Man*_*nan 6

我已下载源代码并遵循文档,这两个事件都与您的示例一起正常工作.

HTML部分:

<button id="openbox" href="#fl1">Load Lightbox on click event</button>
<div class="lightbox" id="fl1">
    <h2>Delete Item</h2>
    <div class="row">
        <div class="twelve columns">
            <strong>Are you Sure?</strong>
            <br>blubblub?
        </div>
    </div>
    <div class="right"> <a href="#" class="btn btn_gray no text_none" id="close_button">Close</a>
    <a href="#" class="btn btn_red text_none">Yes</a>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

jQuery部分:

<script type='text/javascript'> 
    window.onload=function(){
        $('button.#openbox').featherlight({
            targetAttr: 'href',
            beforeOpen: function(event){
                alert('beforeOpen');
            },
            afterOpen: function(event){
                alert('afterOpen');
            }
        });
    }           
</script>
Run Code Online (Sandbox Code Playgroud)

检查这个正在运行的JSFiddle

如果您需要任何其他帮助,请告诉我.