autocomplete - repeat searches no results.
Hello all! First time in the forums.
I have setup an
autocomplete text field, linked to a db datasource that is loaded through an ajax json call. I have noticed that if a
perform a search (e.g. "ch"), then backspace and
perform the exact same search, the
results dropdown will not appear the second time. This only happens if performing the exact same search
twice in a row. If I do another search (e.g. "chr"), the second time, then do my original search I will get the results dropdown as expected. I've noticed this is also the case on the examples for the autocomplete control.
Is there a way around this?
Thanks in advance.
setup source code:
- $(document).ready(function() {
- // Do Auto Complete
- var cache = {};
- $('#txtStaffSutoComplete').autocomplete({
- minLength: 2,
- delay: 100,
- source: function(request, response) {
- $.ajax({
- type: "POST",
- url: "/Modules/Revenue/RevenueAjaxHelper.aspx/GetStaff",
- cache: false,
- dataType: "json",
- data: "{\"searchTerm\" : \"" + request.term + "\"}",
- contentType: "application/json; charset=utf-8",
- success: function(data) {
- response(data.d);
- }
- });
- },
- select: function(event, ui) {
- $('#txtStaffSutoComplete').val(ui.item.StaffName);
- // Work with selected item here.
- return false;
- }
- }).data("autocomplete")._renderItem = function(ul, item) {
- return $("<li></li>").data("item.autocomplete", item).append("<a>" + item.StaffName + "</a>").appendTo(ul);
- };
- });