views:

60

answers:

1

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

A: 

This should work:

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

It will clear the cache after they select the country.

babonk