Infinite Scrolling Paging

◇◆丶佛笑我妖孽 提交于 2019-12-14 03:43:11

问题


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:


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>


来源:https://stackoverflow.com/questions/27898439/infinite-scrolling-paging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!