简体   繁体   中英

Parallax not working when being redirected from another page?

So I have an application that uses parallax and it is being executed once the document is ready

Javascript:

$(document).ready(function(){
  parallax();

});

function parallax() { 
  $('.parallax').parallax();
}

navbar.html.erb:

<a href="/#about-us" onclick="parallax()">About Us</a>
<%= link_to "Why invest with us?", investor_portal_index_path %>

The problem is, when the page is redirected and you go back to the homepage parallax no longer works and the images aren't being loaded either. Is there a way to get around this? I tried calling the parallax function after an onClick event but that is not working either.

Thanks!

I believe you can the parallax in the footer of the web app. So it would look something like this:

<footer
    <script function($){
        $(function(){
          $('.parallax').parallax();
        });
      })(jQuery);
    </script>
</footer>

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM