summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-10-18 08:10:57 -0400
committerScott González <scott.gonzalez@gmail.com>2011-10-18 08:10:57 -0400
commitb41873ba0dd8f84ec282f77d029c7dc0ee99b873 (patch)
tree20801f0ec8e0af959479d7ed0cb2701fd2cfcc07
parent1e2fcb9f4b6c92a7df402829ba5abce3fae7884d (diff)
downloadjquery-ui-b41873ba0dd8f84ec282f77d029c7dc0ee99b873.tar.gz
jquery-ui-b41873ba0dd8f84ec282f77d029c7dc0ee99b873.zip
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.
-rw-r--r--ui/jquery.ui.autocomplete.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 4b332d5a6..1ad9f22bc 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -215,6 +215,13 @@ $.widget( "ui.autocomplete", {
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
+ self.beforeunloadHandler = function() {
+ self.element.removeAttr( "autocomplete" );
+ };
+ $( window ).bind( "beforeunload", self.beforeunloadHandler );
},
destroy: function() {
@@ -225,6 +232,7 @@ $.widget( "ui.autocomplete", {
.removeAttr( "aria-autocomplete" )
.removeAttr( "aria-haspopup" );
this.menu.element.remove();
+ $( window ).unbind( "beforeunload", this.beforeunloadHandler );
$.Widget.prototype.destroy.call( this );
},