Grails:向下滚动页面时加载数据 [英] Grails: Load Data while Scrolling Page Down
本文介绍了Grails:向下滚动页面时加载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是可能的吗?
我想在动态加载数据的同时滚动GSP Page Down 使用grails 1.3.7表示感谢。
解决方案
您可以检测scroller是否已达到结尾的页面。如果是这样,只需加载新的信息。类似于
$(window).scroll(function(){
if($(window).scrollTop )$ $(document).height() - $(window).height()){
loadNewData();
}
});
函数loadNewData(){
/ *添加代码以获取新内容并将其添加到DOM * /
}
下面是一个关于jsFiddle的例子
I want to dynamically load data while Scrolling a GSP Page Down like facebook does.
Is that possible ?
I am using grails 1.3.7 thanks.
解决方案
You can detect whether scroller has reached the end of page. If so, just load new piece of information. Something like
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
loadNewData();
}
});
function loadNewData(){
/* add code to fetch new content and add it to the DOM */
}
Here is an example on jsFiddle
这篇关于Grails:向下滚动页面时加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文