【问题标题】:prettyPhoto breaks other jsprettyPhoto 打破了其他 js
【发布时间】:2013-04-22 09:59:38
【问题描述】:

我正在使用 prettyPhoto 来展示我的照片,但是当我使用它时会破坏其他 js。

    <script src="/js/UItoTop/js/easing.js" type="text/javascript"></script>
    <script src="/js/UItoTop/js/jquery.ui.totop.js" type="text/javascript"></script>
    <link rel="stylesheet" media="screen,projection" href="/js/UItoTop/css/ui.totop.css" />

    <!-- Media LightBox -->
    <link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />
    <script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

    {literal}  
        <script type="text/javascript">
            onload = function(){
                readyVisorFotos();
            }
        </script>
        <script type="text/javascript">
            $(document).ready(function() {

            var defaults = {
                containerID: 'toTop', // fading element id
                containerHoverID: 'toTopHover', // fading element hover id
                scrollSpeed: 1200,
                easingType: 'linear' 
            };

            $().UItoTop({ easingType: 'easeOutQuart' });

            });
        </script>

当我使用 prettyPhoto 时,UItoTop 停止工作。 UItoTop 工作正常,只要您不单击任何图像即可启动 prettyPhoto。

readyVisorFotos()的代码是

   function readyVisorFotos(){
$("a[rel^='prettyPhoto']").prettyPhoto({show_title:false,autoplay_slideshow: true,slideshow: 5000});
$(".clipping a[rel^='prettyPhoto']").prettyPhoto({show_title:true,autoplay_slideshow: true,slideshow: 5000});
$(".noticiabrief a[rel^='prettyPhoto']").prettyPhoto();
 }

谁能帮帮我?

【问题讨论】:

  • 控制台有错误吗?
  • 您不能将readyVisorFotos(); 移动到准备好的DOM 吗?或者也许在加载所有内容时尝试$(window).load(function(){ readyVisorFotos(); });
  • 谢谢蒂姆,但我试过了,还是不行
  • @monchyrcg 你应该把你的代码放到网上或者放到 jsfiddle 里,人们会帮助你的。
  • 好的,这里是所有代码pastebin.com/uFaWv6xH

标签: jquery prettyphoto


【解决方案1】:

我使用回调。

 function readyVisorFotos(){
$("a[rel^='prettyPhoto']").prettyPhoto({show_title:false,autoplay_slideshow: true,slideshow: 5000,callback: function(){UItoTop();}});
$(".clipping a[rel^='prettyPhoto']").prettyPhoto({show_title:true,autoplay_slideshow: true,slideshow: 5000,callback: function(){UItoTop();}});
$(".noticiabrief a[rel^='prettyPhoto']").prettyPhoto({show_title:false,callback: function(){UItoTop();}});
}

function UItoTop(){
var defaults = {
    containerID: 'toTop', // fading element id
    containerHoverID: 'toTopHover', // fading element hover id
    scrollSpeed: 1200,
    easingType: 'linear' 
};
$().UItoTop({ easingType: 'easeOutQuart' });
}

【讨论】:

    猜你喜欢
    • 2013-07-16
    • 1970-01-01
    • 2015-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-25
    • 1970-01-01
    相关资源
    最近更新 更多