JQuery Fancybox 2.0.5 syntax error

I am trying to implement Fancybox v2.0.5 into my page. Before that I used 1.3.4 with no problem.

The problem is that when .fancybox () was called on an element, I get this error whenever I click anywhere on the page :

Uncaught Error: Syntax error, unrecognized expression: )


I was able to figure out that this has something to do with the fact that I wrap certain elements in anchors, calling it like this:

var $a = $("<img/>", {src:"path_to_img", alt:"YT afbeelding"})
                .wrap('<a href="#yt_editor" class="yt_vid" rel="'+video_id+'" />')


Does anyone know how to fix this?


source to share

1 answer

Personally, I would call this a plugin bug. The problem is how you get the initialization call setup. I think this should work:

$('.yt_img').wrap("<a href='#' class='yt_img_wrapper'/>");


The problem is that the plugin expects to be able to use the internal jQuery "selector" value as a way to access the element (s) that the plugin was called on, and (in my opinion) that only a bad design solution. The selector in your case is ".yt_img.parent ()", which is not a valid selector; which triggers a syntax error exception.

edit - it is already registered as issue # 173 in the GitHub bug list for Fancybox.



All Articles