Got it! Oh Lord, after 5 days with this headache! ^^
The final code I got running is this one below, all the other code remains the same:
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").on("click", function() {
var $id = this.href.split("#");
$("#ajaxFancyBox").load("generate_gallery.php?gallery="+$id[1], function() {
$(".fancybox_gallery").fancybox({
// fancybox API options here
'padding': 0,
helpers : {
title : {
type: 'outside'
},
thumbs : {
width : 50,
height : 50
}
}//helpers
});//fanxybox
$(".fancybox_gallery").first().trigger('click');
});// load
return false;
$.fancybox(this); // << CHANGED THIS
});//on
});//ready
</script>
If you have a best and simple way to do this please answer the question with a improved code!
Thanks to @JFK, I've searched all your posts and found this one, that helped me a lot.