As the name implies, the pop state event is fired only when the event is called from the story, and not when the record is inserted into the story.
In your example, if you have two history entries, the first entry that occurs when the page is loaded from the server, and the second one that you just clicked.
When you click the back button of the browser, the state that you get in the case is the original entry, starting with the page loading. The popstate event gives you the state you are currently in, and not the state that was just popped out of the stack. A bit confusing.
In your example, if you pushed two records onto the stack, both with status data and with the "Back" button, your event handler should show you the state data of the first state that you put on the history stack.
source share