]> source.dussan.org Git - jquery-ui.git/commitdiff
Autocomplete: Re-enable native autocomplete whent he page is unloaded. Fixes #7790...
authorScott González <scott.gonzalez@gmail.com>
Tue, 18 Oct 2011 12:10:57 +0000 (08:10 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 18 Oct 2011 12:10:57 +0000 (08:10 -0400)
ui/jquery.ui.autocomplete.js

index 4b332d5a6a98665f8de104230bda66620e2eaac6..1ad9f22bc701d1c30229452269f5566c164a06dc 100644 (file)
@@ -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 );
        },