jQuery autocomplete ajax request doesn't update
<p>I have this code to do jquery autocomplete:</p>

<pre><code>var suggestions = [];

function complete(){
    // jQuery Autocomplete
    $('#q').autocomplete({
        source: suggestions,
        select: function(event, ui) {
            window.location = '/play/' + ui.item.display_id;
            event.preventDefault();
        },
        focus: function (event, ui) {event.preventDefault();}
    }).bind('focus', function(){
        if($(this).val().length &gt; 0){
            $(this).autocomplete("search");
        }
    }).autocomplete('instance')._renderItem = function(ul, item){
        return $("&lt;li&gt;").append("&lt;a href='/play/" + item.display_id + "' class='row'&gt;\
                &lt;span class='col-sm-3'&gt;&lt;img height=\"50px\" src=\"" + item.icon + "\"&gt;&lt;/span&gt;\
                &lt;span class='col-sm-9'&gt;&lt;p&gt;" + item.title + "&lt;/p&gt;&lt;p style=\"white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:1.3rem;\"&gt;" + item.short_description + "&lt;/p&gt;&lt;/span&gt;\
            &lt;/a&gt;")
            .appendTo(ul);
    };
}
</code></pre>

<p>I then have this that makes an ajax request and returns new results:</p>

<pre><code>gs.search.suggest($this.val(), function(err, data){
    if(err){return;}
    suggestions = data;
    complete();
});
</code></pre>

<p>Here is what it looks like within the page:</p>

<pre><code>var delay = null;
$('#q').on('keypress', function (e) {
    if (e.keyCode == 13) {
        e.preventDefault();
        search($(this).val());
    }else{
        $this = $(this);
        clearTimeout(delay);
        delay = setTimeout(function() {
            gs.search.suggest($this.val(), function(err, data){
                if(err){return;}
                suggestions = data;
                complete();
            });
        }, 200);
    }
});
</code></pre>

<p>It works, but not as I type. When I type something I then have to remove focus from the input box, and focus back on the input box for the results to display. I need them to display right away (as I type).</p>