JQuery tools: how to close an overlay?

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

Both do not 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 wrong in FF.

+7
jquery dialog popup overlay jquery-tools
source share
7 answers

Like this:

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

For most of your scenarios, you call the original method, for example. .overlay() then call the method you want on this object.

+16
source share

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

 var overlay = $("a[rel]").overlay({ ... api:true }); overlay.close(); 
+10
source share

The problem with assigning an overlay to a class is that there will be many overlay elements, so everything should be closed:

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

Alternatively, you can simulate a click on the close button:

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

 $('.caddy_grid_overlay .close').click(); 
+5
source share

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

+2
source share

It will work for you, please see the code here.

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

Link:

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

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

+2
source share
  $(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' }); 
+1
source share

You can create a function and call it from whatever you want.

this function will work based on class name and reference.

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

  overlay.close(); } 
0
source share

All Articles