Im using pagination.js in order to implement ajax pagination. My code look like this:
function postsPagination(category, count){
(function(name) {
var container = $('#pagination-' + name);
container.pagination({
dataSource: '{{ route("ajax.posts") }}?category=' + category,
locator: 'items',
totalNumber: count,
pageSize: 40,
ajax: {
beforeSend: function() {
container.prev().html('Loading...');
}
},
callback: function(response, pagination) {
var dataHtml = '<ul class="col-sm-12 myposts">';
$.each(response, function (index, item) {
dataHtml += `<a href="{{ route('frontend.myposts', ['slug' => '']) }}/` +item.slug+ `">
<figure class="psot__container" style="background-image: url({{ asset('/uploads/posts/` +item.cover+ `') }})">
<figurecaption><p>` +item.name+ `</p></figurecaption>
</figure>
</a>`;
});
dataHtml += '</ul>';
container.prev().html(dataHtml);
}
})
})('posts');
}
This function is called after loading website and when user check an category. It works correctly but how I can implement routung to this script? When I talk about routinmg I mean about js routing just like in React, Angular, etc. After check category and page I want to change an url without reaload.