Popstate event in repeater

Tanachai Thürling asked on January 3, 2019 11:15

Hello everyone,

i am struggling with the popstate event in a repeater. What I am trying is to listen on the popstate event in case a user uses the implemented Back Button or the browser Back Button. But it seems that the popstate event is not being triggered.

I tried to use the popstate like this:

window.popstate = function(e) {
    alert('hello onpopstate');
}

and

window.onpopstate = function(e) {
    alert('hello onpopstate');
}    

Both seem not to be affected by "history.back()" or browser-back. What I try to achieve is to set an Item into the localstorage as soon as the button(implemented / browser) is being clicked.

Recent Answers


David te Kloese answered on January 3, 2019 17:05

Why would you do this in a repeater? Even if it worked you'd fire the event for every record of the repeater.

Can't you just set data in local storage on page load?

0 votesVote for this answer Mark as a Correct answer

Tanachai Thürling answered on January 3, 2019 17:14

My goal is to write something into the localstorage as soon as the "history.back()" is being called. Therefore i need to catch the browsers-"history.back()" aswell... Any idea on how I can catch the event?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.