3

very simple question (but I can't find the answer on the Web...): I have an autocomplete field being set this way:

$(document).ready ->
         $('#projecttask_user_name').autocomplete
                 source: "/autocomplete/users"

I would like jquery to trigger the source when I select the field in order to get the full list of possibilities even if I haven't typed anything in the field.

How can I do this? Thanks!

1 Answer 1

6

You can set the minLength option to 0, and call the search method when the input element gains focus:

$("#projecttask_user_name").autocomplete({
    source: "/autocomplete/users",
    minLength: 0
}).focus(function() {
    $(this).autocomplete("search", this.value);
});
Sign up to request clarification or add additional context in comments.

Comments

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.