{"id":1709,"date":"2022-08-30T15:18:47","date_gmt":"2022-08-30T15:18:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/29\/conditionally-load-fancybox-resources-with-yepnope-js-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:47","modified_gmt":"2022-08-30T15:18:47","slug":"conditionally-load-fancybox-resources-with-yepnope-js-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/conditionally-load-fancybox-resources-with-yepnope-js-collection-of-common-programming-errors\/","title":{"rendered":"Conditionally load Fancybox resources with Yepnope.js-Collection of common programming errors"},"content":{"rendered":"<p>You&#8217;ll need to use the callback feature of yepnope. The way you have it now, it tries to execute <code>jQuery(\"#gallery a\").fancybox()<\/code> at the same time as requesting the <code>fancybox.pack.js<\/code>. It doesn&#8217;t load the files sequentially. The callback is triggered each time a resource is loaded, you&#8217;ll need to verify the URL.<\/p>\n<p>This should work, or get you started at least:<\/p>\n<pre><code>yepnope({\n    test : jQuery('body').hasClass('edizioni'),\n    yep  : ['\/assets\/css\/jquery.fancybox.css','\/assets\/js\/libs\/jquery.fancybox.pack.js','\/assets\/js\/libs\/jquery.mousewheel-3.0.6.pack.js'],\n    callback: function (url, result, key) {\n        if(url === \"\/assets\/js\/libs\/jquery.fancybox.pack.js\"){\n            \/\/ Fancybox has loaded, it's safe to call it now\n            jQuery(\"#gallery a\").fancybox();\n        }\n    }\n});\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-29 06:07:52. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>You&#8217;ll need to use the callback feature of yepnope. The way you have it now, it tries to execute jQuery(&#8220;#gallery a&#8221;).fancybox() at the same time as requesting the fancybox.pack.js. It doesn&#8217;t load the files sequentially. The callback is triggered each time a resource is loaded, you&#8217;ll need to verify the URL. This should work, or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1709","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1709"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1709\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}