jackmoore / colorbox

A light-weight, customizable lightbox plugin for jQuery
http://www.jacklmoore.com/colorbox/
MIT License
4.75k stars 1.14k forks source link

Colorbox not recognizing "onClosed" #807

Closed mckrti closed 7 years ago

mckrti commented 7 years ago

I have a colorbox that appears upon clicking a link. Within the colorbox is a cancel button that calls $.colorbox.close(). However, the onClosed callback never fires.

$('input#close-comment-form').on('click', function(e) {
        $.colorbox.close({
            onClosed: function() {
                console.log('hi2');
            }
        });
});

I'm not sure what the problem is. The colorbox does fade away, but the console.log never fires.

I'm guessing it has something to do with this:

This method initiates the close sequence, which does not immediately complete. The lightbox will be completely closed only when the cbox_closed event / onClosed callback is fired.

jackmoore commented 7 years ago

The close method takes no arguments, so the options object you've passed it here is going to be ignored. The colorbox method ($.colorbox(obj) or $(selector).colorbox(obj)) is what takes the option object, so you would use it when assigning Colorbox to an element, or when opening Colorbox directly.

mckrti commented 7 years ago

You didn't really answer my question, but I figured it out on my own anyway.