Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I combine multiple events in a jQuery UI autocomplete?
    primarykey
    data
    text
    <p>In the code below, I have the same function on three different events (focus, select, change). This seems redundant but I can't figure out how to combine the three into one. Thanks in advance for any ideas!</p> <pre><code>$("input[name^='addSchool']").autocomplete({ source: function (request, response) { var temp = $("input[name^='addSchool']").attr("name"); var tempteacherID = temp.split(":"); var teacherID; teacherID = tempteacherID[1] $.ajax({ url: "JSONschools.asp", dataType: "json", data: { term: request.term, teacherID: teacherID }, success: function (data) { response(data); } }); }, focus: function (event, ui) { //if the value of the textbox does not match a suggestion, clear its value if (!ui.item) { $(this).val(''); $(this).parent("li").next().html("Please select only from the list shown").effect("pulsate", { times: 3 }, "slow"); } else { $(this).next().val(ui.item.id); } }, select: function (event, ui) { //if the value of the textbox does not match a suggestion, clear its value if (!ui.item) { $(this).val(''); $(this).parent("li").next().html("Please select only from the list shown").effect("pulsate", { times: 3 }, "slow"); } else { $(this).next().val(ui.item.id); } }, change: function (event, ui) { //if the value of the textbox does not match a suggestion, clear its value if (!ui.item) { $(this).val(''); $(this).parent("li").next().html("Please select only from the list shown").effect("pulsate", { times: 3 }, "slow"); } else { $(this).next().val(ui.item.id); } }, minLength: 2 }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload