dpjjr42626 2015-01-12 09:07
浏览 43
已采纳

无限滚动分页

Can anyone tell how to implement Infinite Scrolling Paging for $flickr->call('flickr.photos.search'); I've the user logged in and the first 10 set of photos. Now how to implement scrolling paging for remaining photos.

I am using * Flickr API Kit with support for OAuth 1.0a for PHP >= 5.3.0. And Codeigniter

Any Help would be appreciated....

  • 写回答

1条回答 默认 最新

  • douba3975 2015-01-12 09:08
    关注

    Give unique id value for the div that contains the story in your design and use Jquery to Post the value to your controller using Ajax Post then retrieve next set of Flickr data. Once you've the results append it below the last div.

    Your View Page looks like:

    <div class="flickr_container">       
    <div class="flickr_myphotos" id="<?php echo $fli; ?>">
    {your flickr photos here }
    </div>
    
    <div class="flickr_myphotos" id="<?php echo $fli; ?>">
    {your flickr photos here }
    </div>
    .........
    </div>
    

    Your Jquery Scroll event looks like:

    $('.container').bind('scroll', function(){
    
    if($(".container").scrollTop() + $(".container").innerHeight()>=$(".container")[0].scrollHeight)
        {
    
                var LastDiv = $(".flickr_myphotos:last");
                var LastId  = $('.flickr_myphotos').last().attr('id');
                var dataString = 'LastId='+ LastId ;
    
                if(dataString){
                    $.ajax({
                    type: "POST",
                    url: "{ Controller here }",
                    data: dataString,
                    cache: false,
                    success: function(html){
                    LastDiv.after(html);
    
                    });
    }
    

    And your Controller function:

    $parameters = array('user_id' => {USER ID HERE} ,'per_page' => 10,'page' => $page); $result = $flickr->call('flickr.photos.search', $parameters);

    Place the result in view

    <div class="flickr_myphotos" id="<?php echo $fli; ?>">
    {your flickr photos here }
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波