44

I am using jcarousel, and on window resizing I am getting the error:

jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...

How can I avoid this error?

Halayem Anis
  • 7,654
  • 2
  • 25
  • 45
nirmal
  • 1,111
  • 2
  • 10
  • 14

11 Answers11

97

Just provide the option 'itemFallbackDimension'

Example:

jQuery('#yourcarousel').jcarousel({
    scroll: 1,
    visible: 1,
    animation: 3000,
    auto: 8,
    wrap: 'circular',
    itemFallbackDimension: 300
});

If, for some reason, jCarousel can not detect the width of an item, you can set a fallback dimension (width or height, depending on the orientation) here to ensure correct calculations.

starball
  • 20,030
  • 7
  • 43
  • 238
15

This error shows up when the css file bundled is not attached or not correctly attached ... you have to correctly apply it (the name of the skin goes into the id or the ul).
Example : the class of the ul must be set to jcarousel-skin-tango or to jcarousel-skin-ie7

Falcon
  • 1,461
  • 3
  • 15
  • 29
10

I've just encountered this problem and neither the above, nor any other solution I found fixed the problem. If anyone's still encountering this I fixed it as follows:

  1. Upgrade to latest version of jCarousel if not already on latest.
  2. Define the itemFallbackDimension property when you create your jCarousel instance, with it set to either the height or width, depending on whether you're using jCarousel in horizontal or vertical orientation, e.g:

    jQuery('#imageScroller').jcarousel({ scroll :1, itemFallbackDimension:588 });

Hopefully that will help you as it did me.

Halayem Anis
  • 7,654
  • 2
  • 25
  • 45
4

This is by design, you must set the width and height of each image:

<li><img src="" width="75" height="75" alt="" /></li>
Joe Ratzer
  • 18,176
  • 3
  • 37
  • 51
  • i have set width and height for all the images, but still i get the alert message.. – nirmal Sep 24 '10 at 08:16
  • It this all browsers? Are the images all the same size? – Joe Ratzer Sep 24 '10 at 08:47
  • iam generating images in loop.. and all the images are of same size.. but changing the bind function of window resize in jcarosel.js file has stoped display of alert message, so, is there any aleternate way for for passing unbind value from anywhere outside js file – nirmal Sep 24 '10 at 08:59
2

You need to set a height and width on the ul or whatever container holds the images. Check out the css supplied with jCarousel (it is long but only the first few rules are relevant).

Tgr
  • 27,442
  • 12
  • 81
  • 118
1

we got this error when the carousel was in an iframe in an external site.

none of the above answers helped and we only had a packed version of the jcarousel plugin. so we just did the following(along the lines of inmoon's answer):

instead of "isNan" we replaced the "alert" keyword within the source code by a new function's name("myFunc"). then we created that function:

myFunc = function(myParam) {return}

this fixed the error.

now i know this is a dirty hack, but it seemed to help

sashn
  • 2,828
  • 3
  • 20
  • 19
1

I observe this problem if container gallery is hidden display:none

Victor Orletchi
  • 469
  • 1
  • 5
  • 15
1

You just have to update the jcarousel version to its latest version. And it will solve the issue.

Download the latest version here and update the necessary files.

LSN
  • 328
  • 2
  • 14
0

If your gallery is inside UpdatePanel (Ajax) does not work well, if you generated an event within the panel. every thing inside the panel stops or generates an error....

0

just put "~/Content/Carouselcss/skin.css" at proper place.

Arjun
  • 11
  • 2
-1

SOLUTION: Not sure if this is really a solution or workaround, but it does the job of stopping the nagging popup box once and for all (while permitting jCarousel functionality).

  1. Open jquery.jcarousel.pack.js in the ../jcarousel/lib/ directory.

  2. Seach for the word "alert" and you should find a snippet of code like this: Aborting|loop|infinite|an|cause|will|This|items|set|No|jCarousel|alert|class|

  3. Replace "alert" with "isNan": Aborting|loop|infinite|an|cause|will|This|items|set|No|jCarousel|isNan|class|

  4. Refresh the webpage that loads jCarousel and you should no longer get the infinite loop popup error!

James
  • 5,137
  • 5
  • 40
  • 80
inmoon
  • 9