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?
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.
I hope this helps someone...
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
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:
- Upgrade to latest version of jCarousel if not already on latest.
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.
This is by design, you must set the width and height of each image:
<li><img src="" width="75" height="75" alt="" /></li>
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).
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
I observe this problem if container gallery is hidden display:none
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.
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....
just put "~/Content/Carouselcss/skin.css" at proper place.
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).
Open
jquery.jcarousel.pack.js
in the../jcarousel/lib/ directory
.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|
Replace "alert" with "isNan":
Aborting|loop|infinite|an|cause|will|This|items|set|No|jCarousel|isNan|class|
Refresh the webpage that loads jCarousel and you should no longer get the infinite loop popup error!
来源:https://stackoverflow.com/questions/3784925/no-width-height-set-for-items-this-will-cause-an-infinite-loop-aborting