达到并加载无限滚动后,如何重新加载jquery函数 [英] how can i reload jquery functions after Infinite scroll is reached and loaded
问题描述
im使用jquery插件进行无限滚动,除了需要运行的客户端脚本外,它的运行效果非常好.
im using a jquery plugin for infinite scrolling, and its working perfectly except for the client side scripts that need to run.
我的无限滚动脚本是:
<script type="text/javascript">
$('.infinite-container').waypoint('infinite', {
container: 'auto',
items: '.infinite-item',
more: '.infinite-more-link',
offset: 'bottom-in-view',
loadingClass: 'infinite-loading',
onBeforePageLoad: $.noop,
onAfterPageLoad: $.noop
});
</script>
我认为我需要做的是使用以下方式调用服务器端脚本:
what i think i need to do is somehow call my server side scripts using this:
onAfterPageLoad:
我的主要问题是我的Twitter和Facebook按钮无法加载.我所看到的只是单词"twitter",facebook按钮根本不显示. 但是在初始页面上,它们不会加载任何问题.
my key issue is that my twitter and facebook buttons arnt loading. all i can see is the word "twitter" and facebook buttons dont show up at all. But on the initial page they load no problem.
我不知何故需要再次加载它:
i somehow need to load this again:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=***********";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
以及这些:
<script>
$(document).ready(function() {
$('.container').stickem();
});
</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
对于javascript/jquery来说还很新,因此欢迎您提出任何建议.谢谢.
im pretty new to javascript/jquery so any advice is welcome. thanks.
推荐答案
对于Twitter,您需要:
For twitter you need:
twttr.widgets.load()
请参阅: https://dev.twitter.com/discussions/890
对于Facebook,您需要:
For facebook you need:
FB.XFBML.parse();
请参阅: https://developers.facebook.com/docs /reference/javascript/FB.XFBML.parse/
这可以在动态呈现的按钮下方调用.
This can be called below the dynamically rendered buttons.
onAfterPageLoad用于调用函数,如果使用它,请小心地像这样调用它:
onAfterPageLoad is used for calling a function, if using it just be careful to call it like this:
onAfterPageLoad: functionName
不是
onAfterPageLoad: functionName()
但是对于fb/twitter按钮,我认为最好将代码直接放在按钮下方.
However for the issue of the fb/twitter buttons I think you are better off placing the code immediately below the buttons.
这篇关于达到并加载无限滚动后,如何重新加载jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!