Adding a button click event when a Fancybox popup opens

I am trying to add an onclick event button to a button tag when I load a Fancybox popup using the following code:

var processOrder = function(id) {
    $('#processPopupLink').fancybox({
        'hideOnContentClick': false,
        'frameWidth': 850,
        'frameHeight': 695
    }).click();

    $('#processComplete').click(function() {
        alert('debug');
    });
}

However, it does not show the message box, when I click the button, I have no idea why it does not work, any help would be appreciated.

EDIT

I don't want him to click a button, I want her to add onclick to an existing button in the fancybox popup when the fancybox popup opens.

+3
source share
1 answer

From the Fancybox API :

onComplete - will be called once the contents are displayed.

$('#processPopupLink').fancybox({
    onComplete: function() { 
        $('#processComplete').click(function() 
            {
               alert('debug');
            }); 
    }
});
+5
source

Source: https://habr.com/ru/post/1747328/


All Articles