jquery-pjax icon indicating copy to clipboard operation
jquery-pjax copied to clipboard

Include contents as argument in popstate event

Open lencioni opened this issue 11 years ago • 1 comments

At Causes, we are using pjax in conjunction with Reactjs. As we have currently implemented things, when using the back and forward buttons (popstate), the following warning is logged:

React attempted to use reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server.

To prevent this message from happening, we need a way to clean out the markup that was generated by React components before putting them back on the page. It seems like an event handler that listens to the pjax:popstate event is a reasonable place to do this, but the page's contents are not sent along with that event.

This commit includes the contents that will end up on the page when popping state in the pjax:popstate event that is triggered. This will enable us to clean out the bits that are not desired before they hit the page.

lencioni avatar Jun 10 '14 21:06 lencioni

Would the recent pjax:beforeReplace event be good enough for you? We're even improving it further in https://github.com/defunkt/jquery-pjax/pull/403

mislav avatar Jun 17 '14 19:06 mislav