mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 01:52:22 +03:00
Debounce keyup events when searching for existing customers
This commit is contained in:
parent
b794cb6e74
commit
53a6a8c3a8
1 changed files with 55 additions and 41 deletions
|
@ -223,11 +223,19 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
$('#select-customer').trigger('click'); // Hide the list.
|
$('#select-customer').trigger('click'); // Hide the list.
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var filterExistingCustomersTimeout = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event: Filter Existing Customers "Change"
|
* Event: Filter Existing Customers "Change"
|
||||||
*/
|
*/
|
||||||
$('#filter-existing-customers').on('keyup', function () {
|
$('#filter-existing-customers').on('keyup', function () {
|
||||||
|
if (filterExistingCustomersTimeout) {
|
||||||
|
clearTimeout(filterExistingCustomersTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
var key = $(this).val().toLowerCase();
|
var key = $(this).val().toLowerCase();
|
||||||
|
|
||||||
|
filterExistingCustomersTimeout = setTimeout(function() {
|
||||||
var $list = $('#existing-customers-list');
|
var $list = $('#existing-customers-list');
|
||||||
|
|
||||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_customers';
|
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_customers';
|
||||||
|
@ -237,6 +245,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
key: key
|
key: key
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$('#loading').css('visibility', 'hidden');
|
||||||
|
|
||||||
// Try to get the updated customer list.
|
// Try to get the updated customer list.
|
||||||
$.post(url, data)
|
$.post(url, data)
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
|
@ -280,7 +290,11 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
.appendTo($list);
|
.appendTo($list);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.always(function() {
|
||||||
|
$('#loading').css('visibility', '');
|
||||||
});
|
});
|
||||||
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue