简体   繁体   English

从另一个页面重定向时,视差不起作用?

[英]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: 使用Javascript:

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

});

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

navbar.html.erb: 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. 我尝试在onClick事件后调用视差函数,但该方法也不起作用。

Thanks! 谢谢!

I believe you can the parallax in the footer of the web app. 我相信您可以在Web应用程序的页脚中添加视差。 So it would look something like this: 所以看起来像这样:

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

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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