zoukankan      html  css  js  c++  java
  • jQuery实现新浪微博自动底部加载的方法

    jQuery ScrollPagination plugin 是一个jQuery 实现的支持无限滚动加载数据的插件。

    地址:http://andersonferminiano.com/jqueryscrollpagination/

    他的demo下载:http://andersonferminiano.com/jqueryscrollpagination/jqueryscrollpagination.zip

    实例代码:

      $(function(){
                    $('#content').scrollPagination({
                        'contentPage': 'democontent.html', // the url you are fetching the results
                        'contentData': {}, // these are the variables you can pass to the request, for example: children().size() to know which page you are
                        'scrollTarget': $(window), // who gonna scroll? in this example, the full window
                        'heightOffset': 10, // it gonna request when scroll is 10 pixels before the page ends
                        'beforeLoad': function(){ // before load function, you can display a preloader div
                            $('#loading').fadeIn();
                        },
                        'afterLoad': function(elementsLoaded){ // after loading content, you can use this function to animate your new elements
                             $('#loading').fadeOut();
                             var i = 0;
                             $(elementsLoaded).fadeInWithDelay();
                             if ($('#content').children().size() > 100){ // if more than 100 results already loaded, then stop pagination (only for testing)
                                $('#nomoreresults').fadeIn();
                                $('#content').stopScrollPagination();
                             }
                        }
                    });

                    // code for fade in element by element
                    $.fn.fadeInWithDelay = function(){
                        var delay = 0;
                        return this.each(function(){
                            $(this).delay(delay).animate({opacity:1}, 200);
                            delay += 100;
                        });
                    };
                           
                });

  • 相关阅读:
    基于ASP.NET的comet简单实现
    常用的富文本框插件FreeTextBox、CuteEditor、CKEditor、FCKEditor、TinyMCE、KindEditor ;和CKEditor实例
    关于Application.Lock和Lock(obj)
    asp.net 母版页使用详解--转
    ASP.NET 全局变量和页面间传值方法
    黑帽大会2014:10个酷炫的黑客工具
    python之高性能网络编程并发框架eventlet实例
    eCos中的线程与同步
    Ubuntu12.04 下修改Apache端口号
    PHP 之mysql空字符串问题
  • 原文地址:https://www.cnblogs.com/leejersey/p/3666024.html
Copyright © 2011-2022 走看看