0
I’ve looked for it in other places but I couldn’t find a solution that would work for me. This is the site:
http://pedrowebdesign.hol.es/damaso/
These 3 squares at the top, are locations for photos of the services provided to the last 3 customers (presented in slideshow). When I click on any of them, Javascript performs an AJAX call to a PHP script that lists the images of the inserted folders as 'data' attribute in the link. Each client has an image folder. Yes, the site is static. I made a homemade lightbox to not use too many plugins (since I’m using jcycle). The problem is when I close the lightbox.
Whoever is reading, please visit the site (not yet optimized for smartphones and tablets) and click one of the blue boxes at the top. It worked, didn’t it? Now click on the little square in the upper right corner. You may notice that everything closes as expected. Now try one more click on any of the boxes. Very likely it didn’t work. I couldn’t identify the error so far. Could anyone tell me why this is happening? It only works on the first click. Then, just reload the page :/
Here’s the code:
<script type="text/javascript">
$(document).ready(function(){
$('.featured .client').on("click", function(e){
e.preventDefault();
$('body').addClass('active');
$('.modal').fadeIn();
$.ajax({
method: 'GET',
url: '/damaso-cod/gallery.php',
data: "main_dir=client_images&images_dir="+$(this).data('folder'),
success: function(data){
$('.modal').html(data);
$('.modal').cycle({
'next': '#next',
'prev': '#prev'
});
}
});
$('#close-btn').on("click", function(e){
e.preventDefault();
$('.modal').html('').cycle('reinit');
$('.filter').fadeOut();
$('body').removeClass('active');
});
});
});
</script>
I don’t know if I’ll be able to help, but... Was it supposed to be destroying the cycle anyway? I never messed with Cycle, but according to the documentation, call
destroy
removes all events Binds.– Rui Pimentel
@Ruipimentel, as I clean all the div’s HTML when I close the lightbox, has no reason to let Cycle work. The intention is to start each click and end each Vex that the lightbox is closed.
– Pedro Vinícius
Retire
$('#close-btn').on("click",
from within the first$('.featured .client').on("click"
– Jader A. Wagner