|
1 | | -import $ from 'jquery'; |
2 | | - |
3 | 1 | export function initAdminUserListSearchForm() { |
4 | 2 | const searchForm = window.config.pageData.adminUserListSearchForm; |
5 | 3 | if (!searchForm) return; |
6 | 4 |
|
7 | | - const $form = $('#user-list-search-form'); |
8 | | - if (!$form.length) return; |
| 5 | + const form = document.querySelector('#user-list-search-form'); |
| 6 | + if (!form) return; |
9 | 7 |
|
10 | | - $form.find(`button[name=sort][value=${searchForm.SortType}]`).addClass('active'); |
| 8 | + for (const button of form.querySelectorAll(`button[name=sort][value="${searchForm.SortType}"]`)) { |
| 9 | + button.classList.add('active'); |
| 10 | + } |
11 | 11 |
|
12 | 12 | if (searchForm.StatusFilterMap) { |
13 | 13 | for (const [k, v] of Object.entries(searchForm.StatusFilterMap)) { |
14 | 14 | if (!v) continue; |
15 | | - $form.find(`input[name="status_filter[${k}]"][value=${v}]`).prop('checked', true); |
| 15 | + for (const input of form.querySelectorAll(`input[name="status_filter[${k}]"][value="${v}"]`)) { |
| 16 | + input.checked = true; |
| 17 | + } |
16 | 18 | } |
17 | 19 | } |
18 | 20 |
|
19 | | - $form.find(`input[type=radio]`).on('click', () => { |
20 | | - $form.trigger('submit'); |
21 | | - return false; |
22 | | - }); |
| 21 | + for (const radio of form.querySelectorAll('input[type=radio]')) { |
| 22 | + radio.addEventListener('click', () => { |
| 23 | + form.submit(); |
| 24 | + }); |
| 25 | + } |
23 | 26 |
|
24 | | - $form.find('.j-reset-status-filter').on('click', () => { |
25 | | - $form.find(`input[type=radio]`).each((_, e) => { |
26 | | - const $e = $(e); |
27 | | - if ($e.attr('name').startsWith('status_filter[')) { |
28 | | - $e.prop('checked', false); |
| 27 | + const resetButtons = form.querySelectorAll('.j-reset-status-filter'); |
| 28 | + for (const button of resetButtons) { |
| 29 | + button.addEventListener('click', (e) => { |
| 30 | + e.preventDefault(); |
| 31 | + for (const input of form.querySelectorAll('input[type=radio]')) { |
| 32 | + if (input.name.startsWith('status_filter[')) { |
| 33 | + input.checked = false; |
| 34 | + } |
29 | 35 | } |
| 36 | + form.submit(); |
30 | 37 | }); |
31 | | - $form.trigger('submit'); |
32 | | - return false; |
33 | | - }); |
| 38 | + } |
34 | 39 | } |
0 commit comments