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

笑着哭i 提交于 2019-11-27 11:53:52

问题


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?


回答1:


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...




回答2:


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




回答3:


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.




回答4:


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

<li><img src="" width="75" height="75" alt="" /></li>



回答5:


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).




回答6:


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




回答7:


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




回答8:


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.




回答9:


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....




回答10:


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




回答11:


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!



来源:https://stackoverflow.com/questions/3784925/no-width-height-set-for-items-this-will-cause-an-infinite-loop-aborting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!