views:

16

answers:

0

Basically, here's my code:

$("#airway-bills").autocomplete(awbs, { mustMatch: true, autoFill: true });
    $("#airway-bills").focus();
    $("#selected-awbs").val("");

    $("#origin, #destination").change(function() {
        var origin = $("#origin").val();
        var destination = $("#destination").val();
        var element = $(this);

        $.post("../manifest/get_awbs", { origin: origin, destination: destination }, function(data) {
            if(data) {
                awbs = data;
                $("#airway-bills").unautocomplete().autocomplete(awbs, { mustMatch: true, autoFill: true });
            } else {
                element.val('');
                alert("No AWB's match this criteria.");
            }
        });
    });

The field does get turned into an Autocomplete box the first time around. However I want the Autocomplete list items to change to an updated set whenever either the Origin or Destination boxes are updated. The problem is all that happens is the box gets turned into a regular text input field. Running the Autocomplete call outside of the post function works, however the "awbs" variable still contains the old data set.