search: add a CSS class while searching is in progress (#18921)

This commit is contained in:
Frédéric Péters 2019-04-06 22:19:23 +02:00
parent aea9d7db5d
commit fcf8b9b195
1 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,8 @@ $(function() {
{% endfor %}
function update() {
$form.addClass('searching');
var count = {{ cell.search_services|length }};
{% for search_service in cell.search_services %}
if (xhr_{{ forloop.counter }}) xhr_{{ forloop.counter }}.abort();
xhr_{{ forloop.counter }} = $.get(url_{{ forloop.counter }},
@ -29,6 +31,10 @@ $(function() {
function (response) {
xhr_{{ forloop.counter }} = null;
$results_{{ forloop.counter }}.html(response);
count--;
if (count == 0) {
$form.removeClass('searching');
}
}
);
{% endfor %}