mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
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.
This commit is contained in:
parent
1e2fcb9f4b
commit
b41873ba0d
8
ui/jquery.ui.autocomplete.js
vendored
8
ui/jquery.ui.autocomplete.js
vendored
@ -215,6 +215,13 @@ $.widget( "ui.autocomplete", {
|
|||||||
if ( $.fn.bgiframe ) {
|
if ( $.fn.bgiframe ) {
|
||||||
this.menu.element.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() {
|
destroy: function() {
|
||||||
@ -225,6 +232,7 @@ $.widget( "ui.autocomplete", {
|
|||||||
.removeAttr( "aria-autocomplete" )
|
.removeAttr( "aria-autocomplete" )
|
||||||
.removeAttr( "aria-haspopup" );
|
.removeAttr( "aria-haspopup" );
|
||||||
this.menu.element.remove();
|
this.menu.element.remove();
|
||||||
|
$( window ).unbind( "beforeunload", this.beforeunloadHandler );
|
||||||
$.Widget.prototype.destroy.call( this );
|
$.Widget.prototype.destroy.call( this );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user