1

This is rather a simple question, but how do I disable the dropdown of the jQuery Autocomplete? When a user starts typing, I run my own function on the response callback. I don't need anything else to appear. This is what I have:

            $( "#search" ).autocomplete({
                source: "/app/friends",
                minLength: 2,
                response: function( event, ui ) {
                    $(".ui-menu-item").hide(); //i hoped this would work
                    display(ui.content);
                }
            });
3
  • Try commenting out the display(ui.content); line. Commented Dec 22, 2013 at 23:07
  • Not sure why that would do anything since it's my own method. But it didn't work. Commented Dec 22, 2013 at 23:10
  • Oh, ok - didn't realise that was your code. Commented Dec 22, 2013 at 23:14

1 Answer 1

7

According to the documentation for the plugin, there is an open event that fires when the menu opens. You can put some code in that event to hide the drop down:

$( "#search" ).autocomplete({
    source: "/app/friends",
    minLength: 2,
    response: function( event, ui ) {
        display(ui.content);
    },
    open: function( event, ui ) {
        $(".ui-autocomplete").hide();
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

NOTE: that there needs to be added a , before open: for proper syntax, otherwise your (java)script won't work properly. (Since edits need at least 6 characters (why?) I had to post this as comment)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.