onpopstate is running but content is not loading

So I've had this problem with dynamically created drop down lists not retaining their value when the back button is pressed. I was suggested to use pushState. So the pushState fires properly I believe. Here's my code:

function doPushState(lsize) {

    var state = { lotsize: lsize }, title = "lotsize";

    history.pushState(state, title);

So as I mentioned, I have a dynamically created drop down list. So when the user hits back, the selected value of their drop down from before clicking next should be selected. Here's an image of what the drop down looks like:

drop down list

So I wrote the popstate function like this:

$(window).on('popstate', function(event) {

  var state = event.originalEvent.state;

  if (state) {
      lsize1 = state.lotsize;

To my understanding, when the back button is pressed on the browser or the history.back javascript function is called, it should trigger a popstate which I see in the developer's console's event listeners in Chrome.

popstate event listener

Why isn't the alert message popping up? And why isn't it updating the selection of the drop down to the previous state? If anyone can give me any hints that would be great.

Thank you for your help!



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.