Skip to content
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

Can't run a container cleanup before the cache snapshot #721

Open
fredck opened this issue Feb 9, 2020 · 0 comments
Open

Can't run a container cleanup before the cache snapshot #721

fredck opened this issue Feb 9, 2020 · 0 comments

Comments

@fredck
Copy link

fredck commented Feb 9, 2020

When integrating a component within a pjax enabled website, I have a strong need of cleaning up a few elements from the dom before pjax saves the current container snapshot.

At first, I though that the pjax:beforeReplace event was ideal for it - after all, "replace" can be understood like "remove the current one (take the snapshot) and inject the new one". It was too late.

Then, I thought about the pjax:start event... but for that, I went to check the source code:

jquery-pjax/jquery.pjax.js

Lines 370 to 371 in 153262e

fire('pjax:start', [xhr, options])
fire('pjax:send', [xhr, options])

Conclusion:

  • There is zero difference between pjax:start and pjax:send: 
    • it doesn't seem to be useful.
    • they happen way after things "started" and the xhr was "sent".
  • All these events happen after the snapshot has been already taken, a few lines before.

Q1 (proposal): shouldn't pjax:start happen somewhere earlier in the code?

Q2 (help!): how to safely tweak the dom before the snapshot is taken into the cache?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant