cycle - jquery cycle2 initialisation script failing -
i can utilise jq cycle2 fine required options inline within div, preferred style. instead use initialisation script, old method of operation. prefer keep gallery options stuff out of markup , in external .js file wherever possible.
i've made script of options work 'inline' method , linking properly, silently fails , slideshow reverts default setting of fade whereas specify scrollhorz.
also i'm using previous/next buttons , animated cations - captions work without animation , prev/next buttons visible fail completely.
my script in file named 'functionality.js' , believe i've followed instructions 'custom initialisation script' as outlined in api. have relevant plugins in file called 'plugins.js' link fine , you'll see them referenced in console screengrab below.
please see following markup/script (it's straight copy of cycle2 example simplicity) , link console screengrab:
<a href="#"><span class="prevcontrol">prev</span></a> <a href="#"><span class="nextcontrol">next</span></a> <div class="cycle-slideshow"> <img src="http://malsup.github.com/images/p1.jpg" data-cycle-title="spring" data-cycle-desc="sonnenberg gardens"/> <img src="http://malsup.github.com/images/p2.jpg" data-cycle-title="redwoods" data-cycle-desc="muir woods national monument"/> <img src="http://malsup.github.com/images/p3.jpg" data-cycle-title="angel island" data-cycle-desc="san franscisco bay"/> <img src="http://malsup.github.com/images/p4.jpg" data-cycle-title="raquette lake" data-cycle-desc="adirondack state park"/> <div class="cycle-caption"></div> <div class="cycle-overlay"></div> </div>
the linked script:
$('.cycle-slideshow').cycle({ fx: scrollhorz, timeout: 2000, speed: 700, prev: ".prevcontrol", next: ".nextcontrol", caption-plugin: caption2, overlay-fx-sel: "div" });
and here's link a screengrab of console error
if advise appreciated, i'm sure it's simple error!
thanks in advance
there's few simple mistakes in javascript causing cycle fail. when initalising slideshow programmatically, parameters need camelcase instead of using hyphens when they're specified using data attributes. need wrap string-based parameter values quotes otherwise script think variables. here's updated version of example works:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>cycle2 example</title> </head> <body> <a href="#"><span class="prevcontrol">prev</span></a> <a href="#"><span class="nextcontrol">next</span></a> <div class="slides"> <img src="http://malsup.github.com/images/p1.jpg" data-cycle-title="spring" data-cycle-desc="sonnenberg gardens"/> <img src="http://malsup.github.com/images/p2.jpg" data-cycle-title="redwoods" data-cycle-desc="muir woods national monument"/> <img src="http://malsup.github.com/images/p3.jpg" data-cycle-title="angel island" data-cycle-desc="san franscisco bay"/> <img src="http://malsup.github.com/images/p4.jpg" data-cycle-title="raquette lake" data-cycle-desc="adirondack state park"/> <div class="cycle-caption"></div> <div class="cycle-overlay"></div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="http://malsup.github.io/jquery.cycle2.js"></script> <script> $('.slides').cycle({ fx: "scrollhorz", timeout: 2000, speed: 700, prev: ".prevcontrol", next: ".nextcontrol", captionplugin: "caption2", overlayfxsel: "div" }); </script> </body> </html>
i'd use id or class other cycle-slideshow
when setting slideshow programmatically isn't auto initialised cycle plugin.
Comments
Post a Comment