Sam
Sam

Reputation: 327

jquery ui an auto completion result box is on top left corner

I am beginner for jquery, I am implementing jquery ui autocomplete in my app. But when I am practicing example of it, then the result box of the auto population appears on top left corner. I tried all possible ways to bring it down the text box, but no luck. Please guide me, below is the code snippet:

<html>
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

<script type="text/javascript">
    $(document).ready(function(){
        console.log("here");
        var keyList=[{value:"chinese" },
                     {value:"biryani"},
                     {value:"kabab" },
                     {value:"pizza"},
                     {value:"burger"},
                    ];
        $('#keyword').autocomplete({
                source: keyList,
                select: function(event, ui){
                        //$("#sugg-tag").val(ui.item.empUserRole);
                        console.log('select - '+ui.item.value);

                    }
            });

    });
</script>

</head>

<body>

Search keyword <input type="text" id="keyword">

</body>

</html> 

Upvotes: 3

Views: 1616

Answers (1)

Rahul Patel
Rahul Patel

Reputation: 5246

I have checked your code with latest jquery ui it is working fine. I have updated jquery ui with version "1.12.0". please check below snippet.

    $(document).ready(function(){
        var keyList=[{value:"chinese" },
                     {value:"biryani"},
                     {value:"kabab" },
                     {value:"pizza"},
                     {value:"burger"},
                    ];
        $('#keyword').autocomplete({
                source: keyList,
                select: function(event, ui){
                  console.log('select - '+ui.item.value);
                }
            });

    });
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
Search keyword <input type="text" id="keyword">

Upvotes: 4

Related Questions