Skip to content

Commit 81b2ef4

Browse files
committed
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.
1 parent 63374dc commit 81b2ef4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ui/jquery.ui.autocomplete.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,19 @@ $.widget( "ui.autocomplete", {
265265
.zIndex( this.element.zIndex() + 1 )
266266
.hide()
267267
.data( "menu" );
268+
268269
if ( $.fn.bgiframe ) {
269270
this.menu.element.bgiframe();
270271
}
272+
273+
// turning off autocomplete prevents the browser from remembering the
274+
// value when navigating through history, so we re-enable autocomplete
275+
// if the page is unloaded before the widget is destroyed. #7790
276+
this._bind( doc.defaultView, {
277+
beforeunload: function() {
278+
this.element.removeAttr( "autocomplete" );
279+
}
280+
});
271281
},
272282

273283
_destroy: function() {

0 commit comments

Comments
 (0)