The default function is $.fancybox.close
so I might be inclined to do something like...
$.fancybox.originalClose = $.fancybox.close;
$.fancybox.close = function() {
// Do whatever you want. Then do the default behavior:
$.fancybox.originalClose();
};
It's something of a hack, but it has the advantages of not requiring any modification to the library code or to the original markup, not requiring you to directly manipulate event handlers that the library is defining, and automatically invoking your code regardless of how the box gets closed.
To change the behavior for only one specific box, the best thing is to set the modal
property to true
(which will disable all the built-in methods for closing the box), and then you can add your own "Save" or "Close" button that works however you want. The box will never close automatically, but you can close it when you're ready to with the $.fancybox.close()
function.