Zonamaster
Zonamaster

Reputation: 43

PJAX: force entire page to reload on manual refresh, how?

I'm new to pjax and ajax, actually scripting in general. I have a simple pjax implementation which works well except when manually performing a hard reload of a page.

Upon manually reloading a page with a keyboard command or mouse click only the pjax div is reloaded into the browser window instead of the entire page (container frame and pjax div) meaning that about 80% of the page goes away including header, footer, navigation, styles, etc.

I'm looking for a way to force the frame to reload along with the current pjax content instead of the naked pjax content with no frame. Thanks.

Here's a simple reduction of my code:

<a data-pjax='#pjax-container' href="https://10.0.1.8:8890/location/3114">Seattle</a>

<script type="text/javascript">
    $( document ).ready(function() {
    $(document).pjax('[data-pjax] a, a[data-pjax]', '#pjax-container');
    });
</script>

<div id="pjax-container"> ...pjax loaded content... </div>

Upvotes: 2

Views: 2468

Answers (2)

user3889062
user3889062

Reputation: 21

$(document).pjax('[data-pjax] a, a[data-pjax]', '#pjax-container', { push: false, replaceRedirect: false });

Upvotes: 1

hugo how choong
hugo how choong

Reputation: 144

Try this :

$.pjax.reload('#pjax-container')

The documentation of pjax explains the options you can add to it : https://github.com/defunkt/jquery-pjax

Upvotes: 1

Related Questions