diff --git a/js/views-autocomplete-filters-dependent.js b/js/views-autocomplete-filters-dependent.js index c2a194b..e71f0aa 100644 --- a/js/views-autocomplete-filters-dependent.js +++ b/js/views-autocomplete-filters-dependent.js @@ -15,17 +15,22 @@ Drupal.ACDB.prototype.search = function (searchString) { return; } - // See if this key has been searched for before. - if (this.cache[searchString]) { - return this.owner.found(this.cache[searchString]); - } - // Fill data with form values if we're working with dependent autocomplete var data = ''; if (this.owner.isDependent()) { data = this.owner.serializeOuterForm(); } + // See if this key has been searched for before. + if (typeof this.lastData === 'undefined' || this.lastData !== data) { + // Clear the cache if the dependent data has changed. + this.cache = {}; + this.lastData = data; + } + else if (this.cache[searchString]) { + return this.owner.found(this.cache[searchString]); + } + // Initiate delayed search. if (this.timer) { clearTimeout(this.timer); @@ -75,4 +80,4 @@ Drupal.jsAC.prototype.serializeOuterForm = function() { .serialize(); }; -})(jQuery); \ No newline at end of file +})(jQuery);