4
votes

I'm getting below error:

[cycle] terminating; too few slides: 1

Below is the code for jQuery Cycle. I'm not sure why this is coming out in Chrome

var inners = $('ul#output li').cycle().cycle('stop');

        var slideshow = $('ul#output').cycle({
            fx: 'scrollHorz',
            speed: 300,
            timeout: 0,
            startingSlide: 0, 
            before: function() {

                // stop all inner slideshows
                inners.cycle('stop');

                // start the new slide's slideshow
                $(this).cycle({
                    fx: 'fade',
                    timeout: 1000,
                    autostop: true,
                    end: function() {
                        // when inner slideshow ends, advance the outer slideshow
                        slideshow.cycle('next');
                    }
                });
            }
        });

        $.featureList(
                $("#tabs li a"),
                $("#output li"), {
                    start_item  :   0
                }
            ); 

What could be wrong?

2

2 Answers

4
votes

actually this error comes when your sliding elements Less than 2. if you want to run cycle plugin in single element also then go to

jquery.cycle.all.js

and find

if (els.length < 2) {
            log('terminating; too few slides: ' + els.length);
            return;
        }

and change the condition limit to 1 like

if (els.length < 1) {
            log('terminating; too few slides: ' + els.length);
            return;
        }

if you don't want run single element then you should put condition on your language side that render element if elements count > 2

Cheers!

Mudassar Ali

1
votes

It is something with your first line:

var inners = $('ul#output li').cycle().cycle('stop');

You are trying to create .cicle() inside a .cicle(). If you try:

var inners = $('ul#output').cycle().cycle('stop');

It doesn't return any error.