saimaz saimaz - 22 days ago 21
jQuery Question

$.fancybox.close() not working

I know that question was discussed plenty of times, but i tried all suggestions and noone didn't work. I am using fancybox with href atribute where content is loading using ajax.

$('a').fancybox(
{
href:'ajax/test.php',
titleShow:false
});


And in content i had custom close button

<a href="javascript:void(1)" title="close" onclick="$.fancybox.close()">Pirkti prekes</a>


And when i click that i got $.fancybox is undefined.

Answer

Instead of making a onclick it should look like

$('a').click(function(){
 $(this).fancybox.close();
});
Comments