On the question of pjax, forward and backward is normal, f5 refresh is not right, how to break?

recently, I have been working on a single-page web application, and the website is relatively small, so I don"t use other frames, but I use jquery+ajax, but there is a problem with the browser moving forward and backward, so Baidu can use pjax to move forward and backward.
then gave an example, which is really fine, but then the problem arises. If you press f5 directly after partial rendering, the page will only be partially refreshed, and other page elements will be gone. Many people have read this question on the
website, and some people have answered the question, but the answer is that it is not the problem at all, or it is impossible to understand it at all. Which god can help and give us some advice?. How to solve the problem of f5.

Jul.22,2021

$(document).pjax('[data-pjax] a, a[data-pjax]', '-sharpcontainer', {fragment: '-sharpcontainer'})
The correct thing to do is as shown above, the content page should also be a complete page, not just the content part, and then use the fragment option of pjax to replace the content part.

Menu