From c4c72526cff7f6c2dcd93156d73dd330bcb9e0e1 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Mon, 19 Oct 2015 18:16:28 +0200 Subject: Bug 1210078: Going back from the "Match failed" page deletes the values of user fields r=gerv --- js/field.js | 2 ++ js/global.js | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'js') diff --git a/js/field.js b/js/field.js index 2bd8868f8..063d48c47 100644 --- a/js/field.js +++ b/js/field.js @@ -794,6 +794,7 @@ $(function() { else { that.devbridgeAutocomplete(options_user); } + that.addClass('bz_autocomplete'); }); // init autocomplete fields with array of values @@ -809,6 +810,7 @@ $(function() { this.focus(); } }); + that.addClass('bz_autocomplete'); }); }); diff --git a/js/global.js b/js/global.js index b4905e202..dcffc3529 100644 --- a/js/global.js +++ b/js/global.js @@ -51,3 +51,15 @@ function display_value(field, value) { if (translated) return translated; return value; } + +// jQuery auto-completion disables browser native autocompletion, however this +// excludes it from being restored by bfcache. Trick the browser into restoring +// it by changing the autocomplete attribute when a page is hidden and shown. +$().ready(function() { + $(window).on('pagehide', function() { + $('.bz_autocomplete').attr('autocomplete', 'on'); + }); + $(window).on('pageshow', function() { + $('.bz_autocomplete').attr('autocomplete', 'off'); + }); +}); -- cgit v1.2.3-24-g4f1b