samedi 28 janvier 2017

Laravel 5.3 and Ajax Pagination

I'm developing a gaming website and i'm currently doing the matches page of the teams, in this page i have a bootstrap carousel to switch betwin the teams and display the matches of each team, but i have it limited to 5 matches after that i use laravel built in pagination that i've made it to work in ajax, however it when i change page it changes the content of all my teams matches (obviously since i'm replacing div.matches contents) how can i do it to each team instead of replacing every team with the same content?

The pagination works correctly without ajax.

CONTROLLER

$matches = Matche::orderBy('date', 'DESC')->where('team', $team->id)->paginate(5, ['*'], $team->slug);

// it generates like so.. http://ift.tt/2kzGCJU

HTML

<div class="carousel-item">
<div class="matches">

    <div class="matches-box">
       ... Match #1 ...
    </div>
    <div class="matches-box">
       ... Match #2 ...
    </div>

    

</div>
</div>

JAVASCRIPT

$('body').on('click', '.pagination a', function(e){

    e.preventDefault();
    var url = $(this).attr('href');

    $.get(url, function(data){
        $('.matches').html($(data).find('.matches').html());
    });

});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire