무한스크롤
본문
스킨에 올려주신 코드를 따져 보았더니
<?php
$now_row = '';
for ($i=0; $i<count($list); $i++) {
$now_row = $list[$i]['wr_id'];
?>
이런 식으로 해서 작동하네요 그런데 이게 검색한 결과에 대해서는 무한스크롤이 되지 않아...
어떻게 접급해야 될까요?
<script>
var total_page = "<?=$total_page?>";
var now_page = "<?=$page?>";
var roll_page = now_page;
$(window).ready(function(){
console.log(now_page);
if(now_page != 1){
$(".topScroll").show();
}
if(roll_page != total_page){
$(".btmScroll").show();
}
});
$(window).scroll(function(){
var chkBtm = parseInt($(document).height()) - parseInt($(window).height());
if(chkBtm == $(window).scrollTop()){
roll_page++;
if(roll_page <= total_page){
callContent(roll_page,'append');
}
}else if($(window).scrollTop() == 0){
now_page--;
if(now_page > 0){
callContent(now_page,'prepend');
}
}
});
function callContent(a,b){
if(b=='append'){
$(".moreBtm").slideDown();
}else{
$(".moreTop").slideDown();
}
var url = "<?=G5_BBS_URL?>/board.php?bo_table=<?=$bo_table?>&page="+a;
var tbody = "";
var thtml = "";
$.ajax({
type:"POST",
url:url,
dataType : "html",
success: function(html){
tbody = html.split('<tbody>');
thtml = tbody[1].split('</tbody>');
setTimeout(function() {
if(b=='append'){
$(".tbl_head01").find('tbody').append(thtml[0]);
}else{
$(".tbl_head01").find('tbody').prepend(thtml[0]);
}
$(".moreBar").slideUp();
if(now_page == 1){
$(".topScroll").slideUp();
}
if(roll_page == total_page){
$(".btmScroll").slideUp();
}
}, 1000);
},
error: function(xhr, status, error) {
alert(error);
}
});
}
</script>
이를테면
검색된 페이지라면
$.get( "<?=G5_URL?>/bbs/board.php?bo_table=<?=$bo_table?>&ajax_ck=1&sca=<?php echo urlencode($sca) ?>&sfl=mb_id,1&stx=<?php echo $mb_id ?>&page="+page_n, function( data ) {
&sfl=mb_id,1&stx= 이런식으로 작동하면 될거 같은데요...
답변 1
&sfl=mb_id,1&stx= 이건 order by 에 관련된 내용아닌가요? 그리고
&sfl=mb_id,1 이런 변수 값은 존재 할수 없을텐데...
&sfl=mb_id&sfl2=1&stx= 그냥 이러게 던지시고..
받는 페이지에서 sfl 과 sfl2을 변수 처리 해서 합산해버리세요.