From: Scott González Date: Mon, 17 Oct 2011 13:25:36 +0000 (-0400) Subject: Autocomplete: Re-enable native autocomplete whent he page is unloaded. Fixes #7790... X-Git-Tag: 1.9m7~187 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=81b2ef4a6088cb99863c2d318947355a58019362;p=jquery-ui.git Autocomplete: Re-enable native autocomplete whent he page is unloaded. Fixes #7790 - Autocomplete-enabled text input does not keep value when using back button in browser. --- diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 6b9ee4b3a..ab2edfdff 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -265,9 +265,19 @@ $.widget( "ui.autocomplete", { .zIndex( this.element.zIndex() + 1 ) .hide() .data( "menu" ); + if ( $.fn.bgiframe ) { this.menu.element.bgiframe(); } + + // turning off autocomplete prevents the browser from remembering the + // value when navigating through history, so we re-enable autocomplete + // if the page is unloaded before the widget is destroyed. #7790 + this._bind( doc.defaultView, { + beforeunload: function() { + this.element.removeAttr( "autocomplete" ); + } + }); }, _destroy: function() {