MKumar
MKumar

Reputation: 1524

Jquery autocomplete :: clear cache

I am using Jquery autocomplet for two fields, Country and state. I want the states list according to country value and I am getting this too.

My problem is that state auto complete also show the result of previous country seach. I know this is because jquery cache the result.

Some one please guide me how to solve this

My code is below

$('#khk_adressen_LieferLand').autocomplete("/countries/auto_complete_for_countries_list",{
flushCache: function() {
     return this.trigger("flushCache");
  }
});


$('#khk_adressen_LieferPLZ').autocomplete("/postals/auto_complete_for_postals_list", {
               flushCache: function() {
     return this.trigger("flushCache");
  },
  extraParams: {
      country_name: function() { return $("#khk_adressen_LieferLand").val(); }
  }

});

Thansk in advance

Upvotes: 3

Views: 14222

Answers (3)

Zorro
Zorro

Reputation: 175

$("#element").unautocomplete();

$("#element").autocomplete(newData);

Upvotes: 0

Shohel
Shohel

Reputation: 3934

You can do it by this way. you can set everythig....try.........

 $("#setcommonelement_ElementName").autocomplete(data, {
        minChars: 0,
        width: 262,
        matchContains: "word",
        scrollHeight: 220,    
        cacheLength: 0

    });

Upvotes: 1

Ben G
Ben G

Reputation: 26771

This should work:

$("#country_id").result(function()
{
    $("#state_id").flushCache();
});

It will clear the cache after they select the country.

Upvotes: 3

Related Questions