I am using Fancybox together with a slideshow. I have a slideshow that "dynamically" loads items from the database.
<div id="#slideshow">
<div id="#slide-description">
<a href="http://localhost/test.php">Fancybox here</a>
</div>
</div>
Note: Everything inside the #slideshow
div is dynamically generated by jQuery.
My javascript looks like this:
$("#slide-description").on('click', 'a', function() {
console.log('triggerd click!');
$(this).fancybox({
type: "ajax",
ajax: {
dataFilter: function(data) {
return $(data).find("#portfolio-info");
}
},
onComplete: function(){
console.log('done.');
}
});
return false;
});
My problem is that it works ONLY works when I click on the link twice - <a href="http://localhost/test.php">Fancybox here</a>
.
When I click the link the first time, triggered click!
is logged in the console but no GET
request. Then when I click it the second time, it works!
Console:
triggerd click! /* 1st click */
GET http://localhost:8888/raydar/portfolio/frucor-1/ 200 OK /* 2nd click */
triggerd click! /* 2nd click */
done. /* 2nd click */
Any reply would be greatly appreciated as I have already spent a few hours on this.