Jquery自动完成::清除缓存

3

我正在使用Jquery自动完成插件来实现两个字段的功能,分别是国家和州省。

我想根据所选国家显示对应的州省列表,这部分功能我已经实现了。

但是我的问题是,州省自动完成框还会显示上一次选择国家的结果。我知道这是因为Jquery缓存了结果。

请有经验的人指导我如何解决这个问题。

以下是我的代码:

$('#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(); }
  }

});

感谢您事先的预先准备。

请你能否发布你的代码。 - NM.
3个回答

3
这应该可以工作:
$("#country_id").result(function()
{
    $("#state_id").flushCache();
});

当用户选择国家后,它将清除缓存。


1

你可以通过这种方式来做。你可以设置每一项....试试看......

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

    });

0

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

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接