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 6128555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:38:24+00:00 2026-05-23T16:38:24+00:00

What I have so far: I’m currently working on a Lift-based project for work.

  • 0

What I have so far:

I’m currently working on a Lift-based project for work. Within the "Browse" section of our site, we have a list of links that cause a "Details" pane to update to display the contents of that link (and Frames are out of the question). The links are generated by

<li>{SHtml.a(() => {currentItem.set(itemID); Noop}, itemShortText)}</li>

My task is to make it seem like clicking these links changes the page without actually reloading the page. For example, you start out at /browse, then click a link numbered 123. I’m using History.js to change the displayed URL to browse/123. The idea is that the URL displayed is a permalink: I use URL rewriting of the form

LiftRules.statelessRewrite.append {
  case RewriteRequest(ParsePath("browse" :: id :: Nil, _, _, _),_,_) =>
    RewriteResponse("browse"::Nil, Map("id"->id))
}

so that users can bookmark the page and come back later without having to click a link from the browse page.

What’s missing:

This is all well and good, but I run into trouble when using the Back and Forward buttons to navigate around the history. The URL properly displays the address that I visited, but the contents of the details area doesn’t update. I have a JavaScript function that looks for an onpopstate event:

window.onpopstate = function(event){
  if(event.state){
    //this triggers when you navigate back and forward, except when navigating
    //back to the initial page (/browse)
    //figure out the id from the event.state
    alert("popped to id " + id);
    //Want to pass this id back to the server somehow
  } else {
    //this triggers on a normal page load, or when you navigate via a link
    alert("popped with 'false' state");
  }
}

In the case that event.state is not false, I figure out the id of the item that the page should show. Now what I want to do is send that id back to the server somehow so that the Lift side of things can update the page accordingly. Any help would be greatly appreciated!

tl;dr – How can I pass a variable generated in JavaScript back to the Lift side of things for later use?

  • 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-05-23T16:38:25+00:00Added an answer on May 23, 2026 at 4:38 pm

    Another option to call server via AJAX, pass some JSON data as parameters and make server invoke your callback is to use JsonHandler class as shown in Demo Lift Web App.

    Here is the source code

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thus far built an Editor and a Viewer that both work on
I have been using Backbone on a new project and so far have loved
Here's what I have so far but thing aren't really working. (I dragged the
I have searched far and wide on the Internet but have not found anything
The only experience I have so far with a touchscreen interface was one where
This is what I have so far: myArray.map!{ rand(max) } Obviously, however, sometimes the
This is what I have so far: [my1@graf home]$ curl -# -o f1.flv 'http://osr.com/f1.flv'
This is what I have so far - my dropbox public URL creation script
This is what I have as far as code, it is in the first
I'm taking a course in computational complexity and have so far had an impression

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.