mercredi 5 octobre 2016

Infinite Scroll with Laravel 5 on Dynamic Search Results Page

I'm tried to display page with infinite scroll on Laravel 5. I can't append my filter keys and split again.

My javascript file:

var win = $(window);
var paginate = 0;

win.scroll(function() {
  if ($(document).height() - win.height() == win.scrollTop()) {
    paginate += 10;
    <?php $i = 0; ?>
    var postForm = { 
        'filters'     : "@foreach($filters as $filter)[['', '{!! $filter[1] !!}', '{!! $filter[2] !!}']@endforeach",
        'paginate'    : paginate,
        'postCategory': "infinite",
        '_token'      : ""
    };

    $('#loading').show();
    $.ajax({
      url: '',
      data: postForm,
      type: 'POST',
      dataType: 'html',
      success: function(html) {
        $('#campaigns').append(html);
        $('#loading').hide();
      }
    });
  }
});

My Store function

 $filters = $request->get('filters');
 $paginate = $request->get('paginate');
 $campaigns = Campaign::where($filters)->get();
 return view('campaigns.indexDatas')
 ->with('campaigns', $campaigns);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire