Here is the solution that worked for me, however it does not unbind the fancybox in the sense of how the questioner would like to do it.
First, don't declare the fancybox on node, but bind the node to click
event instead:
$(".classOfMiniImage").on("click", window.onImageMiniClicked);
In the handler, you can use your code to check conditions whether you need to display the fancybox or not, and then display it with explicit href
reference:
window.onImageMiniClicked = function () {
if (<your_condition>) {
$.fancybox({
'href': <link_to_full_size_image>,
/* other options below */
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'speedIn': 600,
'speedOut': 600,
'overlayShow': true
});
}
}
Also, you can use a bit another approach and to unbind this handler manually if you don't need the fancybox on these items anymore:
$(".classOfMiniImage").off("click", window.onImageMiniClicked);
Hope it will help someone.