Asp.net MVC中的jQuery分页滚动 [英] Jquery paging scroll in Asp.net MVC
问题描述
我试图搜索2天有关如何在asp.net mvc项目中进行分页滚动.但是我刚刚发现的结果不合时宜.
I tried to search 2 days about how to do the paging scroll in asp.net mvc project. But I just found the result that not fit to mind.
我正在使用asp.net mvc 2,并通过JSON从控制器中检索所有数据,然后将JSON结果显示在我的mvc项目视图中.结果,我在视图中显示了很多产品(将产品放在表中).因此,我想进行分页滚动,以在用户滚动到元素之外时自动在屏幕底部加载新内容,就像Facebook进行状态更新一样.
I am using asp.net mvc 2, and I retrieve all the data from my controller by JSON, and I take the JSON result to display in my view of my mvc project. As the result, there are many products that I display in my views (I put the products in the table). So I want to do a paging scroll to automatically load new content at the bottom of the screen when the user scrolls beyond the element, much like Facebook does with their status updates.
这是一些代码,展示了如何在局部视图中显示JSON:
This is some codes show how I display the JSON in my partial views :
<script type="text/javascript" language="javascript">
$(document).ready(function () {
var url = '<%: Url.Content("~/") %>' + "ProductListing/AllProductListing";
var $parent = $("#productlist").empty();
$parent.append('<br/><table id="myTable" cellpadding="0" cellspacing="0" width="100%" class="productlist" style="margin-left:4px; padding-top:2px;"><tbody>');
var loading = $.getJSON(url,function (product) {
if(product.ja.length == 0){
$('#loading').hide();
$("#productlist").html("<br/><br/><br/><br/><b>There is no product in this category.</b>");
}
while (k < loopK) {
var count_item = 0;
$.each(product.ja, function (index, value) {
//blah blah blah ....
});
}
});
});
</script>
此代码块运行良好.
请提出任何想法或样品.
Any idea or sample please.
谢谢.
推荐答案
Rob Conery写了有关此主题的详细博客文章.
Rob Conery wrote a detailed blog post on this topic.
这篇关于Asp.net MVC中的jQuery分页滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!