I have an AJAX call that is loading data from a database. I have the following AJAX setup
$(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$(document).ajaxStart(function () {
$("#placeholder").removeClass('d-none');
});
$(document).ajaxSuccess(function () {
$("#placeholder").addClass('d-none');
});
});
It's working pretty well until I use the input to search by word / letter. The input is using input event to be triggered but the problem is the following:
When I write something in the Input, the placeholders appear until it shows the results and then hide, but after that when I click outside the Input (remove the focus from the input), the placeholders appear for milliseconds and hide again (blink)
I've made a lot of test and the conclusion is that it's not happening because of the input event. Here is a thread (by me) for this problem.
Which jQuery event can I use to avoid input event trigger when click outside the input
What can cause this behaviour? I really need help.