开发者

jQuery Tools: How to close an overlay?

开发者 https://www.devze.com 2023-01-07 10:22 出处:网络
$(\"a[rel]\").getOverlay().close(); $(\"a[rel]\").close(); B开发者_Python百科oth don\'t work. $(document).ready(function () {
$("a[rel]").getOverlay().close();
$("a[rel]").close();

B开发者_Python百科oth don't work.

$(document).ready(function () {
        $("a[rel]").overlay({
            mask: '#3B5872',
            effect: 'apple',
            onBeforeLoad: function () {
                var wrap = this.getOverlay().find(".contentWrap");
                wrap.load(this.getTrigger().attr("href"));
            },
            onLoad: function () {
                $('.contentWrap form').submit(function (event) {
                    event.preventDefault();
                    $("a[rel]").overlay().close();
                    hijack(this, update_employees, "html");
                });
            }
        });
    });

    function hijack(form, callback, format) {
        $.ajax({
            url: form.action,
            type: form.method,
            dataType: format,
            data: $(form).serialize(),
            success: callback
        });
    }

    function update_employees(result) {
        $("#gridcontainer").html(result);
    }

Any suggestions?

I use Chrome because the onLoad event seems not work correctly in FF.


Like this:

$("a[rel]").overlay().close();

For most of their scripting you call the original method, e.g. .overlay() then call the method you want on that object.


You need to set api:true in properties if you want to close it from js:

var overlay = $("a[rel]").overlay({
    ...
    api:true
});

overlay.close();


The problem, in case of assigning the overlay to a class, is that there will be many overlay elements, so all must be closed:

$.each($(".caddy_grid"), function(i, v){$(v).overlay().close();})

Alternatively, it is possible to simulate a click on the close button:

The class that triggers the overlay in my case is caddy_grid_overlay, so the close button can be accessed as:

$('.caddy_grid_overlay .close').click();


Try

$("a[rel]").data("overlay").close();

I use this to close my overlays.

source : http://forum.jquery.com/topic/having-trouble-timing-jquery-tools-overlay-to-close-after-a-few-seconds


It will work for you, Please refer code here,

var api = $("a[rel]").data("overlay");

api.close();//close this overlay

Reference :

http://jquerytools.org/documentation/overlay/index.html#api

http://jquerytools.org/documentation/scripting.html


 $(document).ready(function() { 
    var overlayObject = $("a[rel]").overlay({ 
        top: 50,
        expose: {
                    color: '#232323',
                    closeOnClick: true
                },

                onClose:function() {   
                    $('#reg-login').hide();
                    $('#reg-register').hide();
                },
        effect: 'apple'
 });    


you can create a function and call it from anywher you want.

this function gonna work based on class name and a link.

function closeOverlay() { alert('aa'); var overlay = $(\"a.ShowOverlay\").overlay({ api:true });

    overlay.close();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号