Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocomplete shows only message N results are available, use up and down arrow keys to navigate. instead show list

my problem is clear.

I'm using jquery autocomplete and i don't know why it shows me only the message:

9 results are available, use up and down arrow keys to navigate.

Without showing me the list of result.

This is my code:

<p class="select-c">
     <label for="fcb">Location</label>
     <input id="fcb" name="fcb" type="text">                        
</p>


$("#fcb").autocomplete({
        source: function (request, response) {
            $.ajax({
                type: "GET",
                dataType: 'json',
                url: "../ws/city/" + request.term,
                async: true,
                success: function( data ) {
                    response( $.map( data, function( item,key ) {
                        return {
                            label: key,
                            value: item.id_town+"#"+item.id_province
                        }
                    }));
                },
                error: function (result) {
                    alert("Due to unexpected errors we were unable to load data");
                }
            });
        },
        minLength: 2
    });

with results like:

enter image description here

What could be the problem??

like image 445
Jayyrus Avatar asked Jul 02 '13 07:07

Jayyrus


3 Answers

  .ui-helper-hidden-accessible {
            display: none;
        }
like image 75
Ngannv Avatar answered Nov 15 '22 23:11

Ngannv


Check your CSS, maybe you are hiding the menu element. Try with:

.ui-autocomplete {
  z-index: 10000000;
}
like image 32
Jonathan Naguin Avatar answered Nov 15 '22 21:11

Jonathan Naguin


Just check if you are importing the correct css to correct the list rendering

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />

And if you also want to remove the message, add the following entry after source

$("#fcb").autocomplete({
    //your source info
   messages: {
        noResults: '',
        results: function() {}
    }
});
like image 45
Anurag Avatar answered Nov 15 '22 21:11

Anurag