colorbox icon indicating copy to clipboard operation
colorbox copied to clipboard

Colorbox not recognizing "onClosed"

Open mckrti opened this issue 10 years ago • 2 comments

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.

mckrti avatar Nov 28 '16 21:11 mckrti

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.

jackmoore avatar Nov 28 '16 22:11 jackmoore

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

mckrti avatar Nov 29 '16 14:11 mckrti