Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8258491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:33:17+00:00 2026-06-08T02:33:17+00:00

I have single page application. All data is retrieved by ajax and rendered on

  • 0

I have single page application. All data is retrieved by ajax and rendered on client. I have the next workflow:

  1. User opens list of items. List has infinity scroll
  2. User scrolls and clicks on item
  3. System makes ajax request, generates new html and replaces previous content
  4. User clicks on browser’s back button
  5. System changes url (historyjs) and router loads items and renders list. But the position of scroll is LOST ! So user needs to scroll to go to the previous position on the list.

How to preserve this position during back / next actions and implement generic solution for all project ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:33:20+00:00Added an answer on June 8, 2026 at 2:33 am

    Here is my solution (coffeescript):

    class window.Explore
      cached_pages = {}
    
      preserve: (url)=>
        current_position = window.pageYOffset || document.documentElement.scollTop || 0
    
        cached_pages[url] = 
          position: current_position
    
      clean: =>
        cached_pages = {}
    
      scroll_back: (url)=>    
        if cached_pages[url]
          $('body').scrollTop cached_pages[url].position
    
    
    window.cached_explore = new Explore()
    
    window.prev_state = undefined
    window.current_state = undefined
    
    $ ->
      History = window.History
      if !History.enabled
        return false
    
      History.Adapter.bind window, "statechange", =>
          # store previous history state
          window.prev_state = window.current_state
          window.current_state = History.getState()
          # preserve each page position before leaving
          if window.prev_state and window.prev_state.hash
            window.cached_explore.preserve(window.prev_state.hash)    
    
          place_match = location.pathname.match(/\/place\/(.*)/)    
    
          # place page
          if place_match
            # retrieve place      
            window.retrieve_place place_match[1], window.search_query, (err, place_dto) ->        
              # render place page
              window.show_place_popup place_dto        
    
          # explore places page
          else if location.pathname is '' or location.pathname is '/'
            # check if a page was already opened
            window.renred_explore_page()
    
            if window.prev_state
              window.cached_explore.scroll_back location.pathname
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a single page application which loads all content through ajax calls to
I have an application where every single page uses a set of data that
Is it possible to implement Single Page Web Application that would have sensitive data,
I have a single page jQuery mobile application that consists of several list views
I'm building a single-page application. At the moment, I also have several independent pages
Basically I have a single page site that scrolls when the user clicks on
I have a nested user control which appears on every single page. It contains
I have a situation on a single page web application. I use address information
Here's what I have. I have an MVC application where all the data is
I am working on single-page AngularJS application that doesn't have any backend but use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.