I am trying to hide the pagination when only one page is needed after a search through the data. I’m using an if statement calling to the id given to the pagination on the html page but it is not working.
this is the pagination.js
[code]
function showHidePagination() {
if(document.getElementById(‘paginationField’).length > 15) {
document.getElementById(‘pagination’).style.display=’none’;
} else {
document.getElementById(‘pagination’).style.display=’block’;
}
}
this is my home.html pagination portion:
[code]
<div class=”pagination” id=”paginationField”>
<nav aria-label=”…”>
<ul class=”pagination”, id=”pagination”>
<li class=”page-item {% if not prev_page_url %}disabled {% endif %} “>
<a class=”page-link” href=”{{ prev_page_url }}” tabindex=”-1″>Previous</a>
</li>
{% for n in page.paginator.page_range %}
{% if page.number == n %}
<li class=”page-item active”>
<a class=”page-link” href=”?page={{ n }}”>{{ n }} <span class=”sr-only”>(current)</span></a>
</li>
{% elif n > page.number|add:-3 and n < page.number|add:3 %}
<li class=”page-item”>
<a class=”page-link” href=”?page={{ n }}”>{{ n }}</a>
</li>
{% endif %}
{% endfor %}
<li class=”page-item {% if not next_page_url %}disabled {% endif %} “>
<a class=”page-link” href=”{{ next_page_url }}”>Next</a>
</li>
</ul>
</nav>
</div>