插件重新上传到服务器后<object [object =“”object] =“”has =“”no =“”method =“”'infinitescroll'=“”> </object>

时间:2014-04-05 06:42:52

标签: jquery tumblr infinite-scroll

我在tumblr blog中收到无限滚动错误。

Uncaught SyntaxError: Unexpected token < jquery.infinitescroll.min.js:6
Uncaught TypeError: Object [object Object] has no method 'infinitescroll' 

问题是,我根本没有改变代码。它在我意外删除了我的服务器中的所有.js之前工作正常。现在我重新上传文件后,它不想工作。

console.log(jQuery.infinitescroll);

返回&#34;未定义&#34;。

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

    <script src="http://www.gamepad.lt/tumblr/js/masonry.pkgd.min.js"></script>
    <script src="http://www.gamepad.lt/tumblr/js/imagesloaded.pkgd.min.js"></script>
    <script src="http://www.gamepad.lt/tumblr/js/jquery.infinitescroll.min.js"></script>
     <script>
    $(document).ready(function() {
        console.log(jQuery.infinitescroll);
        var clHolder = $('#loader-holder'),
        clBubble = $('#bubble'),
        clX = 0, clY = 0, clD = 0,
        clEngaged = true, clInterval;

        function clFunc(){
            clX = Math.round(37 + Math.cos(clD * Math.PI / 180) * 53);
            clY = Math.round(37 + Math.sin(clD * Math.PI / 180) * 53);
            clBubble.css({'top' : clY, 'left' : clX});
            clD = clD + 10;
            if(clD >= 360){clD = 0;}
        }

        if(clEngaged){clInterval = setInterval(function(){clFunc();}, 30);}
        setTimeout(function () {
           clearInterval(clInterval);
           clEngaged = false;
           $('#posts').animate({opacity : 1}, 1000);
        }, 5000);

        var $container = $('#posts');
        var $logo = $('<li class="post logo"><h1><a href="/"><img id="header" src="http://static.tumblr.com/pgmq7uc/5Y1mt16m1/kawaiiandecchi.png"/></a></h1></li>');
        $container.prepend($logo);
        $container.imagesLoaded(function(){
            $container.masonry({
                columnWidth: '.post',
                "gutter": 10,
                transitionDuration: 0,
                itemSelector: '.post'
            });
            clEngaged = false;
            clHolder.animate({opacity : 0}, 1000, function(){
                clearInterval(clInterval);
            });
            $('#posts').animate({opacity : 1}, 1000);
        });

        $("#backToTop").click(function(){
            $("body").animate({scrollTop: '0'},500);
        });

        $container.infinitescroll({
            navSelector  : '#page-nav',
            nextSelector : '#page-nav a', 
            animate : false,
            itemSelector : '.post',
            donetext     : $container.prepend($logo),
            bufferPx     :  50,
            loading: {
              finishedMsg: ''
            }
          },
          function( newElements ) {
            var $newElems = $( newElements );
                $newElems.css({opacity : 0});
            $newElems.imagesLoaded(function(){
                $container.masonry( 'appended', $newElems, false ); 
                $newElems.css({opacity : 1});
            });
          }
        );

        $('#infscr-loading').remove();

        function sortUnorderedList(ul, sortDescending) {
          if(typeof ul == "string")
            ul = document.getElementById(ul);

          var lis = ul.getElementsByTagName("LI");
          var vals = [];

          for(var i = 0, l = lis.length; i < l; i++)
            vals.push(lis[i].innerHTML);

          vals.sort();

          if(sortDescending)
            vals.reverse();

          for(var i = 0, l = lis.length; i < l; i++)
            lis[i].innerHTML = vals[i];

          $('#menu').animate({opacity : 1}, 1000);
        }

        sortUnorderedList("menu", false);
    });
    </script>

1 个答案:

答案 0 :(得分:2)

您缺少无限滚动插件。

您确实将其包含在标题中:

<script src="http://www.gamepad.lt/tumblr/js/jquery.infinitescroll.min.js"></script>

但是这个链接不包含插件的jQuery代码(!):

http://www.gamepad.lt/tumblr/js/jquery.infinitescroll.min.js

使用无限滚动插件的代码更新文件。