From 30d3bcd11ce093238a4fd4c8c26bb688f66c5647 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 1 Feb 2015 19:43:34 +0900 Subject: [PATCH] Use history for saving search state. --- client/scripts/application.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/scripts/application.js b/client/scripts/application.js index 7941817..4d4b99d 100644 --- a/client/scripts/application.js +++ b/client/scripts/application.js @@ -35,7 +35,6 @@ function onReady(geo) { _ctx = { - log: [], geo: geo, query: {} }; @@ -102,7 +101,7 @@ } function saveSnapshot(results) { - _ctx.log.push(results); + window.history.pushState(results); } function outputSnapshot(results, omitValues) { @@ -138,6 +137,12 @@ } } + window.onpopstate = function(state) { + if (state.state) { + outputSnapshot(state.state, false); + } + }; + $(document).on({ ajaxStart: function() { $('#spinner').show();