-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callbacks don't persist after navigating away from a page #29
Comments
Yeah.. when using the back/forward buttons a new pjax request is created from the If all history items were updates to the same page, we could probably do something smart which saves these callbacks and reuses them in popstate when necessary. But the first real page change will clear our javascript persistence and then it won't work. And with the |
At this point I think we should disable support for the |
Agreed.
If the caller adds
What do you think? |
Maybe you can persist using localStorage Api |
I'd like to see this fixed by adding more custom events. Callbacks should be treated as legacy, but we could automatically transform:
into
|
@josh I like that. |
As I wrote in #25:
There's a problem with callbacks in pjax, however: they don't get run when returning to a pjax'd page after navigating away.
For example:
This code will log "pjax!" until you navigate away from the page. Once you return (via the back button) from navigating away, nothing will be printed. We can't persist callbacks with the History API.
This is a problem for the existing
success
,error
, andcomplete
user defined callbacks.Instead, people should use the
start.pjax
andend.pjax
events. We should probably not let anyone use anything else and add more pjax-specific events to make up for it.Unfortunately, it's not that simple. Take the above example. If multiple pjax handlers are using
#main
, how can you tell if theend.pjax
event fired is the one you anticipated?The text was updated successfully, but these errors were encountered: