Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery AJAX from the notice selection deletion button #29381

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions web_src/js/features/admin/common.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import $ from 'jquery';
import {checkAppUrl} from '../common-global.js';
import {hideElem, showElem, toggleElem} from '../../utils/dom.js';
import {POST} from '../../modules/fetch.js';

const {csrfToken, appSubUrl} = window.config;
const {appSubUrl} = window.config;

export function initAdminCommon() {
if ($('.page-content.admin').length === 0) {
Expand Down Expand Up @@ -204,22 +205,18 @@ export function initAdminCommon() {
break;
}
});
$('#delete-selection').on('click', function (e) {
$('#delete-selection').on('click', async function (e) {
e.preventDefault();
const $this = $(this);
$this.addClass('loading disabled');
const ids = [];
const data = new FormData();
$checkboxes.each(function () {
if ($(this).checkbox('is checked')) {
ids.push($(this).data('id'));
data.append('ids[]', $(this).data('id'));
delvh marked this conversation as resolved.
Show resolved Hide resolved
}
});
$.post($this.data('link'), {
_csrf: csrfToken,
ids
}).done(() => {
window.location.href = $this.data('redirect');
});
await POST($this.data('link'), {data});
window.location.href = $this.data('redirect');
});
}
}
Loading