0

There is a way i can manually trigger the select and pass custom data into it? I look into this question, but this just automate the ui and click on the dropdown item. My jQuery autocomplete initialization is look like this:

$("#id_full_name").autocomplete({
    source: "/messages/fax/contact_autocomplete/",
    minLength: 1,
    focus: function(event, ui) {
        event.preventDefault();
    },
    select: function(event, data) {
        if (true) {
            /* Do something */
        } else {
            /* Do something */
        };
    }
}
rrk
  • 15,677
  • 4
  • 29
  • 45
Ballon Ura
  • 882
  • 1
  • 13
  • 36

1 Answers1

0

Just declare an actual function and call the function as needed:

function select(event, data) {
  // ... whatever code
}
$("#id_full_name").autocomplete({
    source: "/messages/fax/contact_autocomplete/",
    minLength: 1,
    focus: function(event, ui) {
        event.preventDefault();
    },
    select: select
});
select(null, "custom data");
Rojo
  • 2,749
  • 1
  • 13
  • 34