JQuery Smooth Div Scroll在循环结束时调用ajax函数

时间:2012-03-17 03:59:30

标签: jquery ajax

我正在使用Smooth Div Scroll在网站上创建滚动条等股票代码。我创建了Ajax函数,它将动态地将数据加载到自动收报机中,并成功地沿着页面底部滚动它。

我想要做的是,一旦显示加载的信息并且它循环并到达循环的结尾,再次调用该函数以重新加载数据并显示任何更改。

我不知道如何在循环结束时调用此函数。关于如何实现它的任何想法?

谢谢!

这是我的平滑div jquery调用的样子

$("div#scrollingText").smoothDivScroll({autoScroll: "always", autoScrollDirection: "right", autoScrollStep: 1, autoScrollInterval: 30});

1 个答案:

答案 0 :(得分:1)

如果你向右滚动,那么autoScrollRightLimitReached回调将在它结束时被触发(如果你提供),所以你可以重新加载内容并从那里重新启动。也许这样的事情(只是猜测一种方法来做到这一点,因为你没有显示你的ajax代码):

function doScroll() {
   $("#scrollingText").load("yourajaxurlhere", function(){
      $(this).smoothDivScroll({
         autoScroll: "always",
         autoScrollDirection: "right",
         autoScrollStep: 1,
         autoScrollInterval: 30,
         autoScrollRightLimitReached : function() {
             // any other cleanup that's needed here, then
             doScroll();
         }
      });
   });
}
doScroll();

或者在您的autoScrollRightLimitReached回调中,您可以使用replaceContent方法:

.smoothDivScroll("replaceContent", "yourajaxurlhere")
相关问题