Skip to content

Commit

Permalink
fix: disable previous/next button on first/last page
Browse files Browse the repository at this point in the history
  • Loading branch information
krantheman committed Oct 9, 2023
1 parent 671e26a commit aee7ba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 1 addition & 4 deletions hrms/www/jobs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
endblock title %} {% block header %}
<h3 class="mt-0 mb-10 jobs-page">{{ _("Job Openings") }}</h3>
{% endblock header %} {% block page_content %}
<meta
id="data"
data-filters="{{ all_filters }}"
/>
<meta id="data" data-filters="{{ all_filters }}" data-no-of-pages="{{ no_of_pages }}"/>
<div class="row">
<div class="col-3 text-15">
<div class="flex align-items-center">
Expand Down
8 changes: 8 additions & 0 deletions hrms/www/jobs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ $(() => {
for (const filter in query_params) {
if (filter === "query") {
$("#search-box").val(query_params["query"]);
} else if (filter === "page") {
const no_of_pages = JSON.parse($("#data").data("no-of-pages"));
const page_no = Number(query_params["page"]);
if (page_no === no_of_pages) {
$("#next").prop("disabled", true);
} else if (page_no > no_of_pages || page_no <= 1) {
$("#previous").prop("disabled", true);
}
} else if (allowed_filters.includes(filter)) {
if (typeof query_params[filter] === "string") {
$("#" + $.escapeSelector(query_params[filter])).prop("checked", true);
Expand Down

0 comments on commit aee7ba0

Please sign in to comment.