开发者

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)
开发者_C百科        {
            $('#<%=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>


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(); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜