0

I used fancybox 2 on my wordpress site and it worked for the longest time but recently it hasn't been working on this page (and other pages using fancybox) http://haniabyanyacole.com/?page_id=110

This is the error i'm getting: Uncaught TypeError: Object [object Object] has no method 'fancybox'

I looked around on the other stackoverflow pages and saw others had similar problems, mostly dealing with multiple jquery libs loaded, but I've only loaded it once, and at the top of the page. Can anyone help?

SOLVED: I ended up loading a previous version of jquery (when the plugin still worked) and it fixed fancybox

jules
  • 25
  • 4

1 Answers1

1

I took a quick peek at your page. Based on the errors, it appears like Fancybox was simply broken by the latest version of jQuery being loaded from here...

http://code.jquery.com/jquery-latest.js

This is the downside to using a CDN containing jquery-latest.js... you'll just never know when the latest jQuery version will break some incompatible out-of-date jQuery plugin.

You'll have to figure out how to edit your Wordpress template to only load the last version of jQuery compatible with your Fancybox... probably version 1.8.3.

http://code.jquery.com/jquery-1.8.3.min.js

Otherwise, investigate if there is an updated version of Fancybox available for use with the latest jQuery, version 1.9.1. (As per this jsFiddle, it already looks like Fancybox 2.1.4 works with jQuery 1.9.1)

Here are the links to all past versions of jQuery for your reference:

http://code.jquery.com/#jquery-all


Also read about the "wp enqueue script" at the following link, since you do not want to load multiple versions of jQuery on the same page...

http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Sparky
  • 98,165
  • 25
  • 199
  • 285
  • Thanks Sparky, your solution worked, I appreciate you answering anyway. I reverted to jQuery 1.8.3 and fancybox was restored. I will read about the enqueue script as well ... – jules Feb 09 '13 at 20:02
  • @jules, see my edits. [Fancybox 2](http://www.fancyapps.com/fancybox/) works with jQuery 1.9.1, so you may want to upgrade the Fancybox code rather than downgrade the jQuery version... your choice. – Sparky Feb 09 '13 at 20:05
  • http://stackoverflow.com/questions/14344289/fancybox-doesnt-work-with-jquery-v1-9-0-f-browser-is-undefined-cannot-read – JFK Feb 09 '13 at 20:16
  • Thanks @JFK, looks like it was fixed with his Jan 10th, 2013, v2.1.4 update: http://jsfiddle.net/hpfj8/ – Sparky Feb 09 '13 at 20:30
  • @Sparky : actually, it was fixed on Jan 16, 2013 when Fancybox v2.1.4 was released (the fancybox change log says Jan 10th but I think is a mistake since [jQuery v1.9.0](http://code.jquery.com/jquery-1.9.0.js) was released on Jan 14) ... all fancybox examples link to the latest version so even old posted code is now updated ;) – JFK Feb 09 '13 at 20:41