You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Bug in overlay with closeOnClick + fix Created Apr 9, 2010

This thread is solved

Views: 2175     Replies: 5     Last reply Nov 13, 2011  
You must login first before you can use this feature

motik

Posts: 1

Registered:
Apr 9, 2010

Bug in overlay with closeOnClick + fix

Posted: Apr 9, 2010

Today I started playing with overlay extension and found a bug with closeOnClick option.
Line #174 is buggy because parents() function can work only with string selectors, not jquery (or dom) objects. Seehttp://stackoverflow.com/questions/245241/jquery-ancestors-using-jquery-objects#245266 .

So the solution is to replace line #174
if (et.parents(overlay).length > 1) { return; }
with:
if (et.parents().index(overlay) != -1) { return; }
Or, if we want to exclude overlay itself too, with:
if (et.parents().index(overlay) != -1 || et[0] == overlay[0]) { return; }

paulyoungdesign

Posts: 3

Registered:
May 28, 2010

Overlay 1.2.2

Posted: May 28, 2010

Reply to: Bug in overlay with closeOnClick + fix, from motik
How can I apply this fix to version 1.2.2?

// when window is clicked outside overlay, we close
if (conf.closeOnClick) {
  $(document).bind("click." + uid, function(e) { 
    if (!$(e.target).parents(overlay).length) {
      self.close(e); 
    }
  });						
}

paulyoungdesign

Posts: 3

Registered:
May 28, 2010

Mask option

Posted: May 28, 2010

Reply to: Overlay 1.2.2, from paulyoungdesign
This worked for me:

.overlay({
mask: { color: null }
});

josephsong

Posts: 2

Registered:
Jun 22, 2010

Don"t forget about the trigger

Posted: Jun 22, 2010

Reply to: Bug in overlay with closeOnClick + fix, from motik
In order to avoid closing when one clicks the trigger the whole conditional should look like this:


// when window is clicked outside overlay, we close
if (conf.closeOnClick) {
	$(document).bind("click." + uid, function(e) { 
		var et = $(e.target);
		if ( (et.parents().index(overlay) != -1 || et[0] == overlay[0])
			||
			(et.parents().index(trigger) != -1 || et[0] == trigger[0]) ){ 
			return; 
		}							
		self.close(e); 
	});						
}	

degibons

Posts: 2

Registered:
Aug 16, 2011

» Bug in overlay with closeOnClick + fix

Posted: Aug 26, 2011

Reply to: Bug in overlay with closeOnClick + fix, from motik
This works fine:

onBeforeLoad: function(){
	var self = this;
	$(document).bind('mouseup.overlay',function(event){
	if($(event.target).closest(self.getOverlay()).length == 0)
	self.close();
	});
},
onClose:function() {
	$(document).unbind('.overlay');
}

gerasimov

Posts: 3

Registered:
Oct 19, 2011

» » Bug in overlay with closeOnClick + fix

Posted: Nov 13, 2011

Reply to: » Bug in overlay with closeOnClick + fix, from degibons
If not closing Overlaet call another that does not work close on click. How can this be isplavrit?