1

I'm using the jQuery AutoComplete plugin to pre-fill a field called 'Model' depending on the name of a 'Car' entered in a previous field.

However, if the user types in 'C' in the 'Model' text box, and then changes the manufacturer and types 'C' in the Model text box again, the same models appear. I believe this must be a cache issue with the AutoComplete plugin. How can I get around this?

Thanks

1 Answer 1

1

The documentation talks about a .flushCache method. Haven't tried it though...

EDIT:

$(document).ready(function () {
    $('.autocomplete_make').keyup(function() {
        $(".autocomplete_model").flushCache();
    });
    $(".autocomplete_model").autocomplete("/AutoComplete/Model.ashx",
    {
        extraParams:
        {
            make: function () {
                return $(".autocomplete_make").val();
            }
        }
    });
});
Sign up to request clarification or add additional context in comments.

4 Comments

how would i implement this? my code is currently: $(document).ready(function () { $(".autocomplete_model").autocomplete("/AutoComplete/Model.ashx", { extraParams: { make: function () { return $(".autocomplete_make").val(); } } }); });
thanks FloydPink. However, that only works if the user is to refresh their page each time. I've found a way of putting it on 'keyup' though and this works great: $(".autocomplete_model").keyup(function () { $(".autocomplete_model").flushCache(); }); Replace your code with this and I'll mark it as the answer :)
Thanks Curt... Please see if this version is what works for you... :)
Wouldn't blur() be a more efficient choice?

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.