jQuery 没有为项目设置宽度/高度。这将导致无限循环。中止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3784925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No width/height set for items. This will cause an infinite loop. Aborting
提问by nirmal
I am using jcarousel, and on window resizing I am getting the error:
我正在使用 jcarousel,在调整窗口大小时出现错误:
jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...
jCarousel:没有为项目设置宽度/高度。这将导致无限循环。正在中止...
How can I avoid this error?
我怎样才能避免这个错误?
回答by Christian Schulz
Just provide the option 'itemFallbackDimension'
只需提供选项“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.
如果由于某种原因,jCarousel 无法检测到项目的宽度,您可以在此处设置后备尺寸(宽度或高度,取决于方向)以确保正确计算。
I hope this helps someone...
我希望这可以帮助别人...
回答by Khalil Khamlichi
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
当捆绑的 css 文件未附加或未正确附加时,会出现此错误……您必须正确应用它(皮肤的名称进入 id 或 ul)。
示例:ul 的类必须设置为jcarousel-skin-tango
或jcarousel-skin-ie7
回答by Alistair Hymanman
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 jCarouselif not already on latest.
Define the itemFallbackDimensionproperty 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 });
- 如果不是最新版本,请升级到最新版本的jCarousel。
创建jCarousel 实例时定义itemFallbackDimension属性,将其设置为高度或宽度,具体取决于您是在水平方向还是垂直方向使用 jCarousel,例如:
jQuery('#imageScroller').jcarousel({ scroll :1, itemFallbackDimension:588 });
Hopefully that will help you as it did me.
希望这会像对我一样帮助你。
回答by Joe Ratzer
This is by design, you must set the width and height of each image:
这是设计使然,您必须设置每个图像的宽度和高度:
<li><img src="" width="75" height="75" alt="" /></li>
回答by Tgr
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).
您需要在ul
保存图像的容器或任何容器上设置高度和宽度。查看 jCarousel 提供的 css(它很长,但只有前几条规则是相关的)。
回答by sashn
we got this error when the carousel was in an iframe in an external site.
当轮播位于外部站点的 iframe 中时,我们收到此错误。
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):
以上答案都没有帮助,我们只有一个打包版本的 jcarousel 插件。所以我们只是做了以下(按照 inmoon 的回答):
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”)替换了源代码中的“alert”关键字,而不是“isNan”。然后我们创建了这个函数:
myFunc = function(myParam) {return}
this fixed the error.
这修复了错误。
now i know this is a dirty hack, but it seemed to help
现在我知道这是一个肮脏的黑客,但它似乎有帮助
回答by Victor Orletchi
I observe this problem if container gallery is hidden display:none
如果容器库是隐藏的,我会观察到这个问题 display:none
回答by LSN
回答by Arjun
just put "~/Content/Carouselcss/skin.css" at proper place.
只需将“~/Content/Carouselcss/skin.css”放在适当的位置。
回答by Claudia
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....
如果您的图库位于 UpdatePanel (Ajax) 内,则如果您在面板内生成了一个事件,则它无法正常工作。面板内的所有东西都会停止或产生错误....