UNPKG

@ministryofjustice/hmpps-digital-prison-reporting-frontend

Version:

The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.

26 lines (21 loc) 753 B
import DprQueryParamClass from '../../../DprQueryParamClass.mjs' export default class Pagination extends DprQueryParamClass { static getModuleName() { return 'pagination' } initialise() { this.pageSizeSelect = document.getElementById('page-size-select') this.initInputsFromQueryParams() this.initSelectEvent() } initSelectEvent() { this.pageSizeSelect.addEventListener('change', () => { this.queryParams = new URLSearchParams(window.location.search) const { name, value } = this.pageSizeSelect this.queryParams.set(name, value) this.queryParams.set('selectedPage', '1') window.history.replaceState(null, null, `?${this.queryParams.toString()}`) window.location.reload() }) } }