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.
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:https://github.com/defunkt/jquery-pjax/blob/153262eda33e31119eabb97cd5f14365580a3b35/jquery.pjax.js#L370-L371
Conclusion:
pjax:start
andpjax:send:
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?