Window pushstate, refreshing on back/forward button

I'm trying to get the page to refresh or load whatever data was there previously.

I have:

//Category Select
function selectChange(){
    $('#sort_by_select').on('change', function(event) {

        var val = $(this).val();

        $('#scene_content').html('');

        if (val == 'categories'){
            loadGamesCategories();
        } else if(val == 'az'){
            push_url = '?sort=a-z';
            window.history.pushState({page: this.href}, 'GAMES', push_url);
            loadGamesAZ();
        }else{
            loadGamesCategories();
        }
    });
}

In my PHP, I have it set to load the correct script based on the 'sort' variable above. So it works if I refresh the page. I just want people do be able to click back on their browser and it loads the previous data.

If someone could help explain it or show me an example, that would be amazing.

Thanks!

Answers:

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.