From 8a2d81790efeec248f01b2f3b0dc60f094e4765a Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 3 Dec 2014 08:30:39 +0100 Subject: [PATCH] =?utf8?q?don=E2=80=99t=20attach=20multiple=20instances=20?= =?utf8?q?of=20event=20handlers?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (This was sending queries over and over if the websocket connection was re-established, for example due to the hourly disconnect.) --- static/instant.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/instant.js b/static/instant.js index e9aa282..09ac733 100644 --- a/static/instant.js +++ b/static/instant.js @@ -143,7 +143,7 @@ connection.onopen = function() { sendQuery(); } - $('#searchform').submit(function(ev) { + $('#searchform').off('submit').on('submit', function(ev) { searchterm = $('#searchform input[name=q]').val(); sendQuery(); history.pushState({ searchterm: searchterm, nr: 0, perpkg: false }, 'page ' + 0, '/results/' + encodeURIComponent(searchterm) + '/page_0'); @@ -152,7 +152,7 @@ connection.onopen = function() { // This is triggered when the user navigates (e.g. via back button) between // pages that were created using history.pushState(). - $(window).bind("popstate", function(ev) { + $(window).off('popstate').on('popstate', function(ev) { var state = ev.originalEvent.state; if (state == null) { // Restore the original page. -- 2.11.4.GIT