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

Your preferred username that is used when logging in.

how to close overlay Created Jun 14, 2009

This thread is solved

Views: 9252     Replies: 22     Last reply Dec 1, 2011  
You must login first before you can use this feature

d3rek

Posts: 4

Registered:
Jun 14, 2009

how to close overlay

Posted: Jun 14, 2009

can anyone help create javascript function to close overlay, i want something like this


<p onclick="closeoverlay()">close!</p>

thanks!

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» how to close overlay

Posted: Jun 14, 2009

Reply to: how to close overlay, from d3rek
Grab the api and use jQuery:


var o = $("a[rel]").overlay({api: true});
// click on paragraph of class pclose closes overlay
$("p.pclose").click(function () {
  o.close();
});


<p class="pclose">close!</p>

mhhtj

Posts: 2

Registered:
Jun 28, 2009

» » how to close overlay

Posted: Jun 28, 2009

Reply to: » how to close overlay, from blacktrash
How to do this, if I hava an external overlay.
As far as I can tell , the external overlay can not get the var o.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » » how to close overlay

Posted: Jun 28, 2009

Reply to: » » how to close overlay, from mhhtj
Ah, the <p> is inside the overlay, and not on the pager from where the overlay is triggered?

I believe this could be the right guess as, the more I think about it, it doesn't make sense otherwise because the overlay closes (at least with the default closeOnClick setting) when you click anywhere on the originating page.

So, if my second guess is right, assign the close to your <p>:


<p class="close">close overlay</p>

If additonally you want to replace the close button, do as instructed in the overlay docs:


$("JQUERY SELECTOR").overlay({
  close: "p.close"
});

Please confirm which of my guesses is right, or rephrase your question.

d3rek

Posts: 4

Registered:
Jun 14, 2009

» » how to close overlay

Posted: Jun 28, 2009

Reply to: » how to close overlay, from blacktrash
it's possible to close overlay when you click on image? or maybe area of image?

thanks.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » » how to close overlay

Posted: Jun 28, 2009

Reply to: » » how to close overlay, from d3rek
Please see above, only with img instead p.

d3rek

Posts: 4

Registered:
Jun 14, 2009

» » » » how to close overlay

Posted: Jul 14, 2009

Reply to: » » » how to close overlay, from blacktrash
your code works perfect if close "button" is outside the overlay. i want to close overlay, if "button" (<p>, <img> or smth) is inside the overlay. can you help me with code? thanks!

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » » » » how to close overlay

Posted: Jul 14, 2009

Reply to: » » » » how to close overlay, from d3rek
I just tested, and as I said, you just have to activate your "button" by assigning the "close" class to it:


<div class="overlay">
  <p class="close">close it!</p>
</div>

If additionally you want to keep the autogenerated close button you have to insert an empty <div> (again assign the "close" class) at the beginning of the overlay:


<div class="close">
  <!-- close button, must be styled with css as usual -->
</div>
<div class="overlay">
  <p class="close">close it!</p>
</div>

In case you want to use a different selector you have to configure the overlay script accordingly:


$("a[rel]").overlay({
  // paragraph of class "myclass" closes overlay
  close: "p.myclass"
});


<div class="overlay">
  <p class="myclass">close it!</p>
</div>

Sampawende

Posts: 6

Registered:
Jul 28, 2009

» » » » » » how to close overlay

Posted: Aug 2, 2009

Reply to: » » » » » how to close overlay, from blacktrash
Hello Blacktrash,

i Tried your solution but it looks like it's not working for me.
I explain my problem.

first i bind my overlays and my triggers as it's show on flowplayer example.

Here is an example of what you can find in my overlayed elements :


<div class="overlay">
     <div id="Content">
            Here you have some content with links
            which have already be bound and work.
            like : <a href="" anTtribue="">a link which is suppose to close the overlay</a>
     </div>
</div>

So what i want is when i click on the link it does something (an ajax code etc.) but i also want to close the overlay at this moment or later for the moment the user don't have to do it.
for the process and cie it works fine but the api.close() function doesn't seem to work.

with an alert(), i can see that the function is called, but my overlay is still there.

i tried all the hint you gave and tried on my own many stuffs but i have no result.

i really don't understand, the alerts i put show me that the function should be working normaly but it doesn't.

So if anyone have an idea it would be kind.

Sampawende

Posts: 6

Registered:
Jul 28, 2009

» » » » » » » how to close overlay

Posted: Aug 2, 2009

Reply to: » » » » » » how to close overlay, from Sampawende
After watching carefuly it seems that the function is acting just like if my overlay was already closed.
dunno why.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » » » » » » how to close overlay

Posted: Aug 2, 2009

Reply to: » » » » » » how to close overlay, from Sampawende
Well, I don't see that you gave your href the "close" class.

Try:


<div class="overlay"> 
     <div id="Content"> 
            The closing link must have the close class:
 <a class="close"
 href="whatever">a link which is supposed to close the overlay</a> 
     </div> 
</div>

You can use a different class name, but then you have to configure the close property accordingly. Look for close in the Properties section of the overlay docs

Sampawende

Posts: 6

Registered:
Jul 28, 2009

» » » » » » » » how to close overlay

Posted: Aug 3, 2009

Reply to: » » » » » » » how to close overlay, from blacktrash
Thank you for answering so fast.

well, actually i also tried to give a class "close" but it still doesn't work for me.

But i think I've understood the problem (even if i don't have the answer yet).

The thing is that i create dynamically overlays with their triggers and bind them.

When i retrieve the API while binding like this :


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

and use it like this :


    overlayAPI.close();

it tries to close the last overlay that's been bound.
So when i'm on it it works fine which is not the case of the others.

So i tried to create a new bind in order to retrieve the desired API like this :


    $(function() { 
        //"#"+dest give me the ID of the current overlay
	overlayAPI = $("#"+dest).overlay({api: true}); 
		});

But still, it doesn't seem to work.
With the last solution above, it even doesn't enter in the close() function.

Sampawende

Posts: 6

Registered:
Jul 28, 2009

» » » » » » » » » how to close overlay

Posted: Aug 3, 2009

Reply to: » » » » » » » » how to close overlay, from Sampawende
Okay, i solved the problem but it's far to be the neatest way :

i added a closeAll function :


,
			
			closeAll : function(){
				$.each(instances, function() {
					this.close();
				});
			},

and then i call it.

i know that's contrary to proper coding but it does the job for the moment.

s0ud

Posts: 2

Registered:
Sep 15, 2009

» » » » » » » » » » how to close overlay

Posted: Oct 5, 2009

Reply to: » » » » » » » » » how to close overlay, from Sampawende
Hi Sampawende, i have the same problem but i'm new with this api. can i ask, how is that you added the function? is it when defining the overlay?


  overlayAPI = $("a[rel]").overlay({
  closeAll : function(){
  $.each(instances, function(){                    
         this.close();                
        });             
    }, api: true});  

or did you use it with the bind?


overlayAPI = $("#"+dest).overlay({api: true}); 

also to call this function would be like this?


overlayAPI.closeAll();

thanks in advance for your help

jaydeeh
Programming makes me want to curse, scream, and do great things!

Posts: 2

Registered:
Sep 3, 2010

This is the way to make an overlay close!!!

Posted: Sep 3, 2010

Reply to: » how to close overlay, from blacktrash
If the overlay has a default close button and you want to trigger it to close automatically, or from some other code use:

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

You can use that statement inside of the click code for another element:

$("#close_overlay").click( function() {
$('.close').click();
});

collymitch

Posts: 4

Registered:
Sep 7, 2010

This worked for me!

Posted: Sep 7, 2010

Reply to: This is the way to make an overlay close!!!, from jaydeeh
I know this is old but I've struggled to find a working example so I just wanted to say that jaydeeh's post worked for me:

I have the default close button and an extra link inside the overlay:


<a onclick="$('.close').click()">Close this overlay...</a>

Works a treat - thanks Jaydeeh!

mirage

Posts: 7

Registered:
Oct 4, 2009

» how to close overlay

Posted: Oct 5, 2009

Reply to: how to close overlay, from d3rek
Just wanted to offer my observations:

The problem exists because you're loading the overlay dynamically (via Ajax). That means the initializing code for the 'close' classes has already executed.

What you need to do is to initialize you close links in the callback of the get request


// taken from the jqueryTools example
$(function() { 
 
    // if the function argument is given to overlay, 
    // it is assumed to be the onBeforeLoad event listener 
    $("a[rel]").overlay({ 
 
        expose: 'darkred', 
        effect: 'apple', 
 
        onBeforeLoad: function() { 
 
            // grab wrapper element inside content 
            var wrap = this.getOverlay().find("div.wrap"); 
            var self = this; 
 
            // load the page specified in the trigger
            // + init events in its callback
            wrap.load(this.getTrigger().attr("href"), function(){
                $('.close', this).click(function(){self.close()});
            }); // end wrap.load
        } // end overly.onBeforeLoad
    } // end overlay config
}); // end document.ready

HTH,
Juergen

dirtybird

Posts: 17

Registered:
Feb 11, 2010

This is what worked for me

Posted: Feb 19, 2010

Reply to: » how to close overlay, from mirage
Juergen's solution was almost correct, although one slight formatting error(?) kept it from working on my end. adding a ); on the second to last close got it working for me.

$(function() {

// if the function argument is given to overlay,
// it is assumed to be the onBeforeLoad event listener
$("a[rel]").overlay({

effect: 'apple',
expose: {
color: '#282828',
loadSpeed: 200,
opacity: 0.7
},


onBeforeLoad: function() {

// grab wrapper element inside content
var wrap = this.getContent().find(".contentWrap");
var self = this;

// load the page specified in the trigger
wrap.load(this.getTrigger().attr("href"), function(){
$('.close', this).click(function(){self.close()});
}); // end wrap.load
}//end overlay.onBeforeLoad

}); // end overlay config
}); // end function

shandley14

Posts: 1

Registered:
Jan 5, 2010

This worked for me... and was super simple.

Posted: Feb 21, 2010

Reply to: This is what worked for me, from dirtybird
<div id="overlay_window_close" onClick="$('#new_login_window').expose().close();"></div>

pab_88

Posts: 2

Registered:
Feb 22, 2010

Overlay not closing after form submit

Posted: Feb 22, 2010

Reply to: This worked for me... and was super simple. , from shandley14
I'm struggling with the same issue. I have a form inside my overlay (which content is from an external page) and when I submit the form I simply want that overlay to close. I just can't get it to work!! So annoying! Can anyone help with some simple code for an example.
Many thanks

lundie

Posts: 1

Registered:
Oct 24, 2011

Overlay close on form submit

Posted: Oct 24, 2011

Reply to: Overlay not closing after form submit, from pab_88
Hi Pab_88,

I am having the same issue trying to get the overlay to close on a form submission. Did you have any luck with this?

Thanks!
Ryan