manager: use ajax to refresh tables using search button (#60118)

This commit is contained in:
Frédéric Péters 2021-12-28 17:31:00 +01:00
parent a33834b613
commit b79f165c4a
1 changed files with 26 additions and 12 deletions

View File

@ -142,19 +142,18 @@
return false;
});
/* confirmation on submit buttons */
$(document).on('click', 'button', function (e) {
if ($(e.target).data('confirm')) {
if (! confirm($(e.target).data('confirm'))) {
e.preventDefault();
return false;
}
} else if ($(e.target).data('url')) {
$(document).on('click', 'button[data-confirm]', function (e) {
if (! confirm($(e.target).data('confirm'))) {
e.preventDefault();
if ($(e.target).attr('rel') == 'popup') {
return displayPopup.apply($(e.target), [e]);
} else {
window.location.href = $(e.target).data('url');
}
return false;
}
});
$(document).on('click', 'button[data-url]', function (e) {
e.preventDefault();
if ($(e.target).attr('rel') == 'popup') {
return displayPopup.apply($(e.target), [e]);
} else {
window.location.href = $(e.target).data('url');
}
});
$(document).on('change', '#id_generate_password', function (e) {
@ -197,6 +196,21 @@
}, 600);
});
$('#search-form button').on('click', function(e) {
e.preventDefault();
$('#search-form').trigger('submit');
return false;
});
$('#search-form').on('submit', function(e) {
var $form = $('#search-form');
if (timer) {
window.clearTimeout(timer);
timer = null;
}
var query = $form.serialize();
update_content('?' + query, {'form': '#search-form', 'values': $form.values()}, true);
return false;
});
if ($('#search-form').length) {
window.history.replaceState({'form': '#search-form', 'values': $('#search-form').values()}, window.document.title, window.location.href)
}