0

My blur event fires but not my click event. If I remove the blur event code the click event works fine.

How do I change the order these events fire?

$.fn.autoComplete = function () {

    $(document).on('click', '#' + settings.resultsDivId + ' tr', function () {
            console.log('click fired');
            $('#' + settings.resultsDivId).hide();
    });

    this.on('blur', function () {
        console.log('blur fired');
        $('#' + settings.resultsDivId).hide();
    });

    function AutoComplete(term) {
        // ajax call stuff
    }
};
user3953989
  • 1,844
  • 3
  • 25
  • 56

1 Answers1

1

Changing click to mousedown solved it. Apparently click fires after blur.

Blur event stops click event from working?

user3953989
  • 1,844
  • 3
  • 25
  • 56
  • 1
    I was just about to post a solution, but if this works then great. My solution was to remove the blur event and instead check if the user clicked on the table or outside it and based on that to hide the table – Alon Eitan Nov 06 '17 at 19:44