Blocksit 瀑布流插件 实现瀑布流数据 异步加载(无限加载)

Blocksit 瀑布流插件 实现瀑布流数据 异步加载(无限加载)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<div style="width:1000px; overflow:hidden; margin:0 auto">    
<div class="kppcl" style="width:1008px; position:relative" id="kppcl">

<div class="kppcld">
<div class="kppcld_t">
<div class="kpic"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'><img src="{#$item.logo#}" width="322" /></a></div>
<div class="kname"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'>{#$item.title#}</a></div>
<div class="kinfor">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>&nbsp;&nbsp;&nbsp;&nbsp;间:</th>
<td>{#$item.start_date#}-{#$item.end_date#}</td>
</tr>
<tr>
<th>&nbsp;&nbsp;&nbsp;&nbsp;点:</th>
<td>{#$item.area_name#}</td>
</tr>
</table>
</div>
</div>
<div class="kppcld_b"></div>
</div>

<div class="kppcld">
<div class="kppcld_t">
<div class="kpic"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'><img src="{#$item.logo#}" width="322" /></a></div>
<div class="kname"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'>{#$item.title#}</a></div>
<div class="kinfor">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>&nbsp;&nbsp;&nbsp;&nbsp;间:</th>
<td>{#$item.start_date#}-{#$item.end_date#}</td>
</tr>
<tr>
<th>&nbsp;&nbsp;&nbsp;&nbsp;点:</th>
<td>{#$item.area_name#}</td>
</tr>
</table>
</div>
</div>
<div class="kppcld_b"></div>
</div>

<div class="kppcld">
<div class="kppcld_t">
<div class="kpic"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'><img src="{#$item.logo#}" width="322" /></a></div>
<div class="kname"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'>{#$item.title#}</a></div>
<div class="kinfor">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>&nbsp;&nbsp;&nbsp;&nbsp;间:</th>
<td>{#$item.start_date#}-{#$item.end_date#}</td>
</tr>
<tr>
<th>&nbsp;&nbsp;&nbsp;&nbsp;点:</th>
<td>{#$item.area_name#}</td>
</tr>
</table>
</div>
</div>
<div class="kppcld_b"></div>
</div>

</div>

<div id="page" style="display: none">
<div class="pages"><b class="page_icon">上一页</b><b>1</b><a href="?p=2">2</a><a href="?p=2" class="nextprev" rel="2">下一页</a></div>
</div>

</div>
<script src="/js/blocksit.min.js"></script>
<script language="javascript" type="text/javascript">
$(window).load( function() {
$('#kppcl').BlocksIt({
numOfCol: 3,
offsetX: 5,
offsetY: 5
});
});

var current_p = 0;
//滚动
$(window).scroll(function(){
// 当滚动到最底部以上100像素时, 加载新内容
if ($(document).height() - $(this).scrollTop() - $(this).height()<100) {
ajax_load_data();
}
});
function ajax_load_data(){
var next_p = $('#page').find('.nextprev').attr('rel');
if(next_p && next_p != current_p){
console.log('nextpage = '+next_p);
current_p = next_p;

$.ajax({
url:'{#url_reset("request/front/ajax","","php")#}',
data:{'act':'ajax_forum','p':next_p},
dataType:'json',
type:'post',
beforeSend:function(){
show_loading_body();
},
complete:function(){
show_loading_body();
},
success:function(data){
if(data.status != undefined && data.status == 'ok'){
if(data.html){
$('#kppcl').append(data.html).BlocksIt('reload');
}

if(data.pages_str){
$('#page').html(data.pages_str);
}
}
}
});
}
}
</script>

参考文章:

http://my.oschina.net/Rayn/blog/123938