Search code examples
jqueryjquery-pluginscyclejquery-cycle

Jquery Cycle, Nested Slideshows, Next / Prev advances through outer AND inner slideshows


This is an extension of this question, here you can see a demo that James created based on the answers: http://jamesmason.co.uk/code/cycle.html

Similar to this example, I am building a nested slideshow with Jquery Cycle in order to create a slideshow with 'Albums'.

My stumbling block is the Next / Prev controls. The goal is to create controls that at the end/beginning of an Album will advance to the next/prev Album and continue. Jame's example only advances within a nested slideshow, requiring the user to select a new Album at the end.

Aside: Malsup's nested slideshow example the Next / Prev controls advance only by entire nested cycles, skipping all inner slides.

I edited Jame's example by adding slideshow.cycle('next'); within the :last-child if statement in the after function. (see here)

This sort-of works, except that it skips the last-child, proceeding immediately to the next Album, and the first-child else if statement doesn't work at all with slideshow.cycle('prev'); for obvious reasons.

Does anyone see a way around this? Any help would be greatly appreciated. Thanks.


Solution

  • Rather than immediately calling slideshow.cycle('next'); when you reach the last child, you need to set the "next" link to call it. To avoid overwriting the behavior of the given "next" link, perhaps you could temporarily replace it with a "next show" link.