From f0a873cf02ed80de62fbda8552f184b1e90888ba Mon Sep 17 00:00:00 2001 From: Michael Schmatz <michaelschmatz@gmail.com> Date: Thu, 8 May 2014 11:17:15 -0700 Subject: [PATCH] Fix #985 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I can’t wait until Chrome has majority market share --- app/views/employers_view.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/employers_view.coffee b/app/views/employers_view.coffee index 44e3861c5..013519447 100644 --- a/app/views/employers_view.coffee +++ b/app/views/employers_view.coffee @@ -50,7 +50,9 @@ module.exports = class EmployersView extends View renderCandidatesAndSetupScrolling: => @render() $(".nano").nanoScroller() - if window.location.hash.length is 25 + if window.history?.state?.lastViewedCandidateID + $(".nano").nanoScroller({scrollTo:$("#" + window.history.state.lastViewedCandidateID)}) + else if window.location.hash.length is 25 $(".nano").nanoScroller({scrollTo:$(window.location.hash)}) sortTable: -> @@ -175,8 +177,13 @@ module.exports = class EmployersView extends View onCandidateClicked: (e) -> id = $(e.target).closest('tr').data('candidate-id') - window.location.hash = id if id + if window.history + oldState = _.cloneDeep window.history.state ? {} + oldState["lastViewedCandidateID"] = id + window.history.replaceState(oldState,"") + else + window.location.hash = id url = "/account/profile/#{id}" app.router.navigate url, {trigger: true} else