question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Old events don't work on history.back()

See original GitHub issue

Issuehunt badges

Apparently GitHub caches but regenerates the DOM between ajax loads. This means that our markup is still there, but no events are attached to it.

I think in many cases they still work because we use global delegated events, but it doesn’t where we use onClick and addEventListener

I don’t think it’s a consequence of #1175 because before it, the old button would still be there and inactive.


To reproduce the bug:

  1. Visit https://github.com/sindresorhus/refined-github/issues
  2. Visit the “Code” tab
  3. Press the “Back” browser button
  4. Click the “Open all (issue)” link above the issue list. It doesn’t work anymore

This is rather annoying, the only solution I can think of is to only use delegated events. Not great.


IssueHunt Summary

fregante fregante has been rewarded.

Backers (Total: $80.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
fregantecommented, Jul 19, 2019

I think our way to solve this would be by using delegated events in the app, maybe using @bfred-it 's library delegate-it. What’s you take?

Delegated events would indeed work, but that means using global delegated events for everything. It’s a solution but not what we’re looking for, there would be too many click listeners and eventually that’s gonna slow you down.

0reactions
issuehunt-app[bot]commented, Jan 21, 2020

@sindresorhus has rewarded $72.00 to @fregante. See it on IssueHunt

  • 💰 Total deposit: $80.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $8.00
Read more comments on GitHub >

github_iconTop Results From Across the Web

history.back() Not Working When Navigating Back on Same ...
I would like to implement a function that ensures prompting back on all browsers to stay within a given domain, and avoid skipping...
Read more >
History.back() - Web APIs - MDN Web Docs - Mozilla
This method is asynchronous. Add a listener for the popstate event in order to determine when the navigation has completed.
Read more >
History go() Method - W3Schools
The history.go() method loads a URL (page) from the history list. The history.go() method only works if the page exist in the history...
Read more >
Browser Back Button does not trigger window.onbeforeunload
If I use router.back() and as documentation states as of now is equivalent of window.history.back() , on an event where previous page is...
Read more >
Page: DOMContentLoaded, load, beforeunload, unload
DOMContentLoaded event – DOM is ready, so the handler can lookup DOM nodes, ... preventDefault() doesn't work from a beforeunload handler.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found