1

计划是在页面内添加一个带有加载滚动条的滚动条。2 个问题:我的加载滚动不起作用 & 我不确定是否应该使用 iframe 来实现加载滚动。主要是因为我的 div 中有一个 jQuery 可排序的、可放置的,并且不确定我是否可以拖到 iframe 之外。任何想法,将不胜感激

$(#win).scroll(function(){
//replaced window with #win, which is the id of the div containg database info
    if($(this)[0].scrollTop() == $(this)[0].height()- $(this).height()){

        //everytime we scroll we have this function activated
    //if statement is saying if we're at the bottom of the page
        //$('div#text').hide();
        $('div#loadMoreComments').show();
    //.show is showing the div above which has the loading animation

    $.ajax({
    url: "loadem.php?lastComment="+ $(".postedComment:last").attr("id"),
     //using get variable to say last comment is equal to + posted 
    //comment which is the last comment that's displayed &
    //that last comment has an id 
    success: function(html){
        if (html){
            $("#postedComment").append(html);
            //if we are at the bottom we will add comments to the page
            //and hide the animation
            $('div#loadMoreComments').hide();
            //$('div#text').show();


        }else{
            $('div#loadMoreComments').replaceWith("<div class='box'><center>Finished Loading</center></div>");
        //if theres no more to scroll then the finished loading will show
        }
    }
    });

    }
});
4

1 回答 1

0
if((jQuery(window).scrollTop()) > (jQuery(document).height() - jQuery(window).height()))
{
 ...... YOUR CODE IS HERE.....
}

此代码将用于您页面的连续分页。就我而言,它不会影响可排序、可放置的原因,因为您说分页 div 已经覆盖了所有子元素。

希望这会有所帮助。

于 2012-08-20T14:10:12.993 回答