I'm handling a focus event on an input and it fires an AJAX request to run $.autocomplete() with the results.
$('.section').on('focus', '#title-picker.unfetched', function(e) {
var $titleSearch = $('[name="titlesMode"]:checked');
var getTitles = $titleSearch.val() == "installmentTitles" ? Installment.GetAppList(selectedInstallment) : Installment.GetAllAppList();
getTitles.done(function(result) {
//stuff happens here
Was focus triggered by a click in the input?
or
Was focus triggered by 'change' event attached to input[name="titlesMode"]
}).fail(function(error){
console.error(error);
});
})
.on('change', 'input[name="titlesMode"]', function() {
$('#title-picker').addClass("unfetched");
if ($('#title-picker').val() != '') $('#title-picker.unfetched').trigger('focus');
});
I'm also triggering -with $.trigger('focus'), that triggers if the input has a value and fetches results again, depending on the search mode.
I just need to figure out if the focus event was triggered by a mouse clicking in the input or if it was triggered by $.trigger().
I found some code for differentiating the click event's origin but nothing for focus event :/
Any ideas?