Skip to content

Commit

Permalink
fix: add null check for pagination element before adding event listen…
Browse files Browse the repository at this point in the history
…er (#234)


![2025-01-06_15-48-10](https://github.com/user-attachments/assets/bd532417-750b-44e6-97db-0bbaef467467)

```release-note
修复在 pagination 不存在时添加事件监听器的问题
```
  • Loading branch information
VoidYun authored Jan 6, 2025
1 parent 4776b49 commit 04ae864
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion templates/modules/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@

<script th:inline="javascript">
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("pagination").addEventListener("change", (event) => {
const paginationSelect = document.getElementById("pagination");

if (!paginationSelect) {
return;
}

paginationSelect.addEventListener("change", (event) => {
const selectedPage = event.target.value;
window.location.href = `[(${context})]page/${selectedPage}`;
});
Expand Down

0 comments on commit 04ae864

Please sign in to comment.