closing one overlay and opening another
in Using jQuery
•
10 years ago
I've seen posts about similar things, and tried to make them work for my case, but am clearly doing something wrong.
I have a page where an overlay is invoked by clicking on an image. In the code behind, some links are added to the overlay that's created such that if you click them, I want another overlay to be created and the first one to disappear. The layout of the first and second overlays are the same, though the "child" overlays don't have further "links" embedded.
What's happening is that the first overlay comes up fine, but when I click one of the links to bring up the second overlay, the first overlay disappears, but the second isn't invoked and I'm back to my base page. Then, if I click the image again to bring up the first overlay, both overlays appear, the second one tiled in front of the first. What am I doing wrong?
Here is a simplified form of the resultant html:<img rel="#1208" src="/images/testsmall.png" />
<div class="simple_overlay" id="1208">
<img src="/images/testlarge.png" />
<a rel="#1208_a>link a</a>
<div class="simple_overlay" id="1208_a">
<img src="/images/testlarge_a.png" />
</div>
<a rel="#1208_b>link b</a>
<div class="simple_overlay" id="1208_b">
<img src="/images/testlarge_b.png" />
</div>
</div>
<script>
$(document).ready(function () {
$("img[rel]").overlay({
onBeforeLoad: function (event) {
$('.scrollbar').hide("fast");
$('.thumb').hide("fast"); },
onClose: function (event) {
$('.scrollbar').show();
$('.thumb').show();}
});
$("a[rel]").overlay({
onBeforeLoad: function (event) {
$('img[rel]').overlay().close(); // close the first overlay
$('.scrollbar').hide("fast");
$('.thumb').hide("fast"); },
onClose: function (event) {
$('.scrollbar').show();
$('.thumb').show();
}
});
});
</script>
Any help would be greatly appreciated.
1