views:

44

answers:

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  A: 

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();
            }
        }
    });
});
Floyd Pink
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(); } } });});
Curt
Have edited the answer to try and change the code...
Floyd Pink
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 :)
Curt
Thanks Curt... Please see if this version is what works for you... :)
Floyd Pink
Perfect :) Cheers
Curt