jquery waypoint仅在第一次添加元素

时间:2015-01-12 10:38:16

标签: jquery jquery-waypoints jquery-pagination

我想用jquery和ajax请求进行一个路标分页。我第一次添加正确,但随后添加更多内容必须在滚动上下移动

这是我的HTML

<div id="lista_planes" class="span_of_4">
<div class="col-md-3 span1_of_4">
<div class="col-md-3 span1_of_4">
<div class="col-md-3 span1_of_4">
<div class="col-md-3 span1_of_4">
</div>
这是我的Js

&#13;
&#13;
var pagina = 2;
    var hayMasPlanes = true;
    var opts = {
        offset: '100%'
    };
    $('#verMas').waypoint({
        handler: function(direction){
            if(direction == 'down'){
             $.get('<?php echo Router::url(array('action' => 'ajaxPlanes')) ?>/' + pagina, '',
                function (dato) {
                    
                    if(dato == ''){
                        $('#verMas').hide();
                    }
                    pagina++;
                    $('#lista_planes').append(dato);
                    
               }
               );
        }},
        offset: '50%'
    });
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

Solveeed。 添加Waypoint.refreshAll();在ajax请求中

&#13;
&#13;
$('#verMas').waypoint({
        handler: function(direction){
            if(direction == 'down'){
             $.get('<?php echo Router::url(array('action' => 'ajaxPlanes')) ?>/' + pagina, '',
                function (dato) {
                    
                    if(dato == ''){
                        $('#verMas').hide();
                    }
                    pagina++;
                    $('#lista_planes').append(dato);
                    Waypoint.refreshAll();
               }
               );
        }},
        offset: '50%'
    });
&#13;
&#13;
&#13;