mko
mko

Reputation: 7325

Jquery autocomplete problem with focus

Jquery autocomplete does not work when TextBox control is focused on PageLoad.

Is this a know issue, or is there a way to fix this problem?

Thanks

<head>
<script type="text/javascript">



$(document).ready(function() {
    $("#<%=txtSearchTerm.ClientID%>").autocomplete("Acc.ashx", {
        scroll: true, max: 30, selectFirst: true,
        formatItem: function(item) { return item.toString().split("#")[0]; },
        formatResult: function(item) { return item.toString().split("#")[0]; }
    });

    $("#<%=txtSearchTerm.ClientID %>").result( function findValueCallback(event, data, formatted)
    {
        if(data)
        {
            $('#<%=hidOID.ClientID %>').val(data[0].toString().split('#')[1]);
            $('#<%=butSearch.ClientID %>').attr("disabled", false);
        }   
        else
        {
        $('#<%=butSearch.ClientID %>').attr("disabled", true);
        }         
    });

    });


    </script>
</head>


/body>
</html>

<script>

$(document).ready(function() {
$('#txtSearchTerm').focus();
});

</script>

Upvotes: 0

Views: 4719

Answers (1)

Dhanasekar
Dhanasekar

Reputation: 31

I also faced the same problem as "Jquery autocomplete not firing on keyup unless focus changes" and to fix the issue, I followed the $('#selector').focus(); suggestion provided by Val and it worked for me. Here is my change

$('#inputBox').autocomplete(data);          
$('#inputBox').focus(); 

Upvotes: 3

Related Questions