I managed to create ajax pagination with select options dropdown. It works, but I want to change it to bootstrap pagination to be more user friendly.
Select pagination
<label for="pages">Pages</label>
<select id="pages" name="Filter[page]" class="custom-select">
{% for i in 1..pages %}
{% if i == page %}
<option id="page{{ i }}" value="{{ page }}" selected>{{ page }}</option>
{% else %}
<option id="page{{ i }}" value="{{ i }}">{{ i }}</option>
{% endif %}
{% endfor %}
</select>
Select pagination converted to Bootstrap pagination
<div id="paginationWrap">
{% if pages > 1 %}
<ul class="pagination justify-content-center">
{% if page > 1 %}
<li class="page-item-icon">
<a class="page-link" href="{{ page - 1 }}" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
{% endif %}
{% for i in 1..pages %}
<li class="page-item {{ i == page ? 'active' : null }}">
<div id="page{{ i }}" class="page-link">{{ i }}</div>
</li>
{% endfor %}
{% if pages > page %}
<li class="page-item-icon">
<a class="page-link" href="{{ page + 1 }}" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
{% endif %}
</ul>
{% endif %}
</div>
Javascript
$(document).on("click", ".page-link", function() {
var pageClickValue = $(this).attr('id');
var pageValue = pageClickValue.substring(4)
console.log(pageValue);
$('#paginationWrap').val(pageValue);
var $form = $(this).closest('form');
console.log($form);
$form.request();
});
Here is the problem, If click any of bootstrap pagination pages (1 or 2 or 3) it always returns "next" page and then it stops working. Every next click I only see ajax request being sent but nothing changes (Only first click works). Is there any other way to convert this select dropdown even to radio button pagination, since this don't works?