NivoSlider 在 magento 上运行不顺畅
我正在尝试在我的 magento 安装上实现 nivoslider 。我只是复制粘贴下载的演示包中的内容(我已经在我的 Firefox 上测试过,运行非常流畅)到 magento。我完成了所有作业,
- 将所有必需的 js 和 css 文件复制到主题的皮肤文件夹
将这些文件添加到 page.xml
<块引用><参考名称=“head”>
...css/styles.css ;css/nivo-slider.css <样式表>css/themes/default/default.css ; ;css/themes/default/pascal.css ; <操作方法=“addItem”><类型>skin_js<名称>js/jquery-1.6.2-no-conflict.js<参数/> ; ... <操作方法=“addItem”><类型>skin_js<名称>js/jquery.nivo.slider.pack.js<参数/> <操作方法=“addItem”><类型>skin_js<名称>js/my_own_custom_script.js<参数/> ...css/themes/default/orman.css 复制 magento cms 页面上的滑块 html 部分
- 最后添加
jQuery(document).ready(function($) { $('#slider').nivoSlider(); });
到 my_own-custom_script.js
它运行,但并不顺利。有时幻灯片只是暂停一会儿。其他时候,其中一张图像幻灯片不会显示。动画也有点闪烁。滑块导航(上一个-下一个按钮和滑块底部的圆圈)有时对我的单击事件没有响应。让我感到困惑的是,所有这些症状只是有时发生,有时却运行良好。
哦,还有一件事,每次我用 firebug 检查它的一个元素时,这个 nivoslider 也总是让我的 Firefox 崩溃。
谁能给我一些线索,为什么会发生这种情况?我怀疑这与magento的Prototype脚本的冲突有关(尽管它都已经在无冲突模式下运行)
I'm trying to implement nivoslider on my magento installation. I just copy paste what's in the downloaded demo package (which I've tested out on my firefox and run very smooth) to the magento. I did all the homework
- copy all the required js and css files to my theme's skin folder
add those files on page.xml
<reference name="head"> <action method="addCss"><stylesheet>css/styles.css</stylesheet></action> ... <action method="addCss"><stylesheet>css/nivo-slider.css</stylesheet></action> <action method="addCss"><stylesheet>css/themes/default/default.css</stylesheet></action> <action method="addCss"><stylesheet>css/themes/default/pascal.css</stylesheet></action> <action method="addCss"><stylesheet>css/themes/default/orman.css</stylesheet></action> <action method="addItem"><type>skin_js</type><name>js/jquery-1.6.2-no-conflict.js</name><params/></action> ... <action method="addItem"><type>skin_js</type><name>js/jquery.nivo.slider.pack.js</name><params/></action> <action method="addItem"><type>skin_js</type><name>js/my_own_custom_script.js</name><params/></action> ... </reference>
copy the slider html section on magento cms page
- and finally add
jQuery(document).ready(function($) { $('#slider').nivoSlider(); });
to my_own-custom_script.js
It runs, but not smoothly. Sometimes the slide just paused for a while. The other times, one of the image slide won't showed up. The animation is also a little bit flickering. The slider navigation (the prev-next button and those circle on the bottom of the slider) sometimes get unresponsive on my click event. What makes me confused is, all those symptoms just happen sometimes, some other time it runs well.
oh, one more thing, this nivoslider also always make my firefox crash everytime I inspect one of its element with firebug.
Could anyone give me some clue, why is this happening? I suspect this has something to do with the conflict with magento's Prototype script (although it all already runs in noconflict mode)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过一番挖掘,我找到了解决方案......解决方案非常简单:
就像在 nivoslider 脚本中添加一个小下划线字符一样简单。
只需将 nivoslider 脚本上的这一行替换为:
这里
是对那些需要解释的人的解释:
如果您在使用 nivoslider 时看到错误列表(使用 firefox,ctrl+shift+j),您会发现原型太多了递归。这是对原型“太多递归”的解释: 原型化过多的递归问题。
Prototype 上反向函数的使用与 NivoSlider 发生了冲突。 github上的人发现了这个问题并在这里给出了一个快速解决方案:
https://github.com/gilbitron/Nivo-Slider/issues/35
这个问题让我抓狂,因为到处都没有足够的资源(尝试用谷歌搜索一下,你会发现这个问题没有直接的答案)。所以我希望我的问题以及我自己的答案可以帮助其他与我有同样情况的人:)
after some digging, I found the solution... and the solution is very simple:
as simple as adding one little underscore character to nivoslider script.
just replace this line on nivoslider script:
to this
And here is the explanation for those who need explanation:
if you see the error listing (with firefox, ctrl+shift+j) while using nivoslider, you will see that the prototype got too much recursion. This is the explanation of that "too much recursion" of Prototype: prototype too much recursion problem.
Usage of reverse function on Prototype has made conflict with NivoSlider. guys on github found this problem and give one quick solution here:
https://github.com/gilbitron/Nivo-Slider/issues/35
this problem has drive me crazy, for there are no sufficient resource everywhere (try google it out and you'll find no direct answer to this problem). So I hope my question, along with my own answer could help other people out there with the same case with me :)
最近开始在一个已经开发了一段时间的网站上看到这个。看到:
在 Chrome 的控制台中。 “Object.extend.reverse”详细信息引用了原型行 881。我不太懂 JavaScript,所以这个细节更适合其他人。
/skin/frontend/gas/default/js/jquery.nivo.slider.pack.js 已加载,因此肯定会发生一些冲突,可能与新的 jQuery 版本或其他内容发生冲突。
我想你可以切换到不同的滑块。我最近发现了 BX slider 并且喜欢它,虽然还没有在 Magento 项目上使用它,所以不能说兼容性,而且你已经修复了它,所以......
Started seeing this recently on a site that's been in dev for awhile. Seeing:
in the console in Chrome. the 'Object.extend.reverse' detail references prototype line 881. I'm not much of a javascript guy, so this is a detail better suited for someone else.
/skin/frontend/gas/default/js/jquery.nivo.slider.pack.js is loaded in , so it's gotta be some conflict, maybe with new jQuery version or something.
I suppose you could switch to a different slider. I recently found BX slider and like it, though haven't used it on a Magento project yet, so can't speak for compatibility and you've fixed it anyway, so...