Skip to content

Commit 0676bf5

Browse files
authored
Remove jQuery AJAX from the notice selection deletion button (#29381)
- Removed all jQuery AJAX calls and replaced with our fetch wrapper - Tested the repo notice selection deletion button functionality and it works as before Signed-off-by: Yarden Shoham <[email protected]>
1 parent f9207b0 commit 0676bf5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

web_src/js/features/admin/common.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import $ from 'jquery';
22
import {checkAppUrl} from '../common-global.js';
33
import {hideElem, showElem, toggleElem} from '../../utils/dom.js';
4+
import {POST} from '../../modules/fetch.js';
45

5-
const {csrfToken, appSubUrl} = window.config;
6+
const {appSubUrl} = window.config;
67

78
export function initAdminCommon() {
89
if ($('.page-content.admin').length === 0) {
@@ -204,22 +205,18 @@ export function initAdminCommon() {
204205
break;
205206
}
206207
});
207-
$('#delete-selection').on('click', function (e) {
208+
$('#delete-selection').on('click', async function (e) {
208209
e.preventDefault();
209210
const $this = $(this);
210211
$this.addClass('loading disabled');
211-
const ids = [];
212+
const data = new FormData();
212213
$checkboxes.each(function () {
213214
if ($(this).checkbox('is checked')) {
214-
ids.push($(this).data('id'));
215+
data.append('ids[]', $(this).data('id'));
215216
}
216217
});
217-
$.post($this.data('link'), {
218-
_csrf: csrfToken,
219-
ids
220-
}).done(() => {
221-
window.location.href = $this.data('redirect');
222-
});
218+
await POST($this.data('link'), {data});
219+
window.location.href = $this.data('redirect');
223220
});
224221
}
225222
}

0 commit comments

Comments
 (0)