Mangesh
Mangesh

Reputation: 1031

add close button to ajax fancybox

I am using fancy box 1.3 with ajax option. I want to add close button to popup which will act same as close image on the popup corner so written on click event of close button -

$.fn.fancybox.close()

tried with

`jQuery.fn.fancybox.close()`

none seem to work. I am getting jQuery.fn.fancybox.close() not function error message. here is code.

$('#cancel-filters-btn').click(function(){
            jQuery.fn.fancybox.close();
});

Upvotes: 1

Views: 2220

Answers (4)

fragmentedreality
fragmentedreality

Reputation: 1317

You tried to call the function on no object. Call it on your elements (by selector):

$('#cancel-filters-btn').click(function(){
    $.fancybox.close();
});

Upvotes: 1

Jai
Jai

Reputation: 74738

try delegating the event:

$(document).on('click', '#cancel-filters-btn', function(){
    $.fancybox.close();
});

Upvotes: 2

muthu
muthu

Reputation: 5461

You may try like this

$('#cancel-filters-btn').click(function(){
            $.fancybox.close();
});

Upvotes: 2

Miqdad Ali
Miqdad Ali

Reputation: 6147

please check this one

$('#cancel-filters-btn').click(function(){
           $.fancybox.close();
});

Upvotes: 1

Related Questions