search cell: display only results of the last request (#18916)

This commit is contained in:
Thomas NOËL 2017-09-24 00:14:02 +02:00
parent b1c045204f
commit ec6fb3d109
1 changed files with 4 additions and 1 deletions

View File

@ -14,11 +14,14 @@ $(function() {
var combo_search_form_{{ cell.pk }} = $('#combo-search-form-{{ cell.pk }}');
var combo_search_input_{{ cell.pk }} = $('#combo-search-input-{{ cell.pk }}');
var combo_search_results_{{ cell.pk }} = $('#combo-search-results-{{ cell.pk }}');
var xhr = null;
function combo_search_update_{{ cell.pk }}() {
$.get(combo_search_input_{{ cell.pk }}.data('autocomplete-json'),
if (xhr) xhr.abort();
xhr = $.get(combo_search_input_{{ cell.pk }}.data('autocomplete-json'),
{'q': combo_search_input_{{ cell.pk }}.val()},
function (response) {
xhr = null;
combo_search_results_{{ cell.pk }}.html(response);
}
);