Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit b41873ba0dd8f84ec282f77d029c7dc0ee99b873 1 parent 1e2fcb9
Scott González authored October 18, 2011

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. 8  ui/jquery.ui.autocomplete.js
8  ui/jquery.ui.autocomplete.js
@@ -215,6 +215,13 @@ $.widget( "ui.autocomplete", {
215 215
 		if ( $.fn.bgiframe ) {
216 216
 			 this.menu.element.bgiframe();
217 217
 		}
  218
+		// turning off autocomplete prevents the browser from remembering the
  219
+		// value when navigating through history, so we re-enable autocomplete
  220
+		// if the page is unloaded before the widget is destroyed. #7790
  221
+		self.beforeunloadHandler = function() {
  222
+			self.element.removeAttr( "autocomplete" );
  223
+		};
  224
+		$( window ).bind( "beforeunload", self.beforeunloadHandler );
218 225
 	},
219 226
 
220 227
 	destroy: function() {
@@ -225,6 +232,7 @@ $.widget( "ui.autocomplete", {
225 232
 			.removeAttr( "aria-autocomplete" )
226 233
 			.removeAttr( "aria-haspopup" );
227 234
 		this.menu.element.remove();
  235
+		$( window ).unbind( "beforeunload", this.beforeunloadHandler );
228 236
 		$.Widget.prototype.destroy.call( this );
229 237
 	},
230 238
 

0 notes on commit b41873b

Please sign in to comment.
Something went wrong with that request. Please try again.