P
P
picka2020-04-25 05:38:34
JavaScript
picka, 2020-04-25 05:38:34

Swup.js - how to work with it in general?

document.addEventListener("DOMContentLoaded", function restart() {
                $('.main_page-center_block-portfolio a, .squad_people a').click(function(){
                
                    $('.article_full_screen').addClass("article_full_screen-view");
                    $('.article_full_screen-right_block').addClass("article_full_screen-right_block-view");
                    $('.article_full_screen-left_block').addClass("article_full_screen-left_block-view");
                    $('body').addClass("body-overflow");
                    
                    var href = $(this).attr('href');
                    console.log(href);
                    var toLoad = href +'index.php #article';
                    $('#article').load(toLoad);
                    history.pushState(null, null, href);

                    return false;
                    
                });
       swup.on('contentReplaced', restart);
   });

Swup starts the restart function when the page is initially loaded, I run this script on this page, I go to the next one thanks to Swup, but when I go back and run it again, the url is just an orgy, I see through the console that the request for the href variable occurs several times and that's it it folds up and comes out together.
Comrades, help such a fool as I, preferably not with advice, but by editing the code.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question