fancyapps/fancyBox — Issue #173: fancybox does not work when selector starts not from root
Author: yarosla
Created: 2012-03-04 01:01:34+00:00
State: open

Excerpt from fancybox source code:

$.fn.fancybox = function (options) {
var selector = this.selector || '';
...
if (selector) {
D.undelegate(selector, 'click.fb-start').delegate(selector, 'click.fb-start', run);

} else {
that.unbind('click.fb-start').bind('click.fb-start', run);
}

There are scenarios when selector is non-empty but can not be used to select nodes starting from $(document). For example:

$(document.getElementById('some-id')).children('.ch1').fancybox();

In this case selector === '.children(.ch1)' and evaluating it from $(document).find(selector) gives empty result so fancybox does not function.

This scenario is quite typical when trying to invoke fancybox from whithin other jquery plugin.