"추가로드"버튼에 문제가 있습니다. 결과가 더 이상 없다면 결과가 (1) 제한 인 20 (2)보다 작 으면 버튼을 숨기고 싶습니다. 모든 것이 이미 표시됩니다. 현재, 최선의 노력에도 불구하고 여전히 볼 수 있습니다.결과가 <= 한계에 도달하면 더 많은 버튼을 숨김 CI
내 한계는 20이며 만 4 결과가 있기 때문에 더 버튼이 숨겨져 야이 부하 :
컨트롤러 코드 :
public function get_topic($user_id='')
{
$this->load->helper('text');
$page = $_GET['page'];
$value['posts'] = $this->user_model->get_userpost($user_id,$page);
$this->load->view('themes/default/user/user_topic_post',$value);
}
모델 코드 :
를// get topic post
function get_userpost($user_id,$page)
{
$offset = 20 * $page;
$limit=20;
$this->db->where('status',1);
$this->db->where('user_id',$user_id);
$this->db->limit($limit);
$this->db->offset($offset);
$this->db->order_by('id','DESC');
$query = $this->db->get('threads');
return $query;
}
개
user_topic_post 코드 :
<?php
$CI = get_instance();
$i = 0;
foreach($posts->result() as $post):
$i++;
?>
<tr>
<th scope="row">#<?php echo $i ?></th>
<td><a href="<?php echo base_url("topic/".$post->thread_slug);?>"><?php echo $post->title; ?></a><br/>
<small class="num-result"><?php echo strip_tags(word_limiter($post->content,20)); ?><br/><b>
<?php
$posted_date = $post->created_at;
$now = time();
echo timespan($posted_date, $now, 1).' '.lang_key('ago'); ?></b></small></td>
<td class="num-result text-center"><?php echo custom_number_format($post->post_view); ?></td>
<td class="num-result text-center"><?php echo custom_number_format($CI->threads_model->countTopicReplyByTopicId($post->id)); ?></td>
</tr>
<?php
endforeach; //foreach
?>
내 JS 코드 :
<script>
$(document).ready(function(){
userpost(0);
$(".load-more").click(function(e){
e.preventDefault();
var page = $(this).data('val');
userpost(page);
});
});
var userpost = function(page){
$(".user-topic-post-loading").show();
$(".load-more").show();
$.ajax({
url: "<?php echo base_url("user/get_topic/".$account['id']); ?>",
type:'GET',
data: {page:page}
}).done(function(response){
$(".user-topic-post").append(response);
$(".user-topic-post-loading").hide();
$('.load-more').data('val', ($('.load-more').data('val')+1));
if(response == ""){
$(".load-more").hide();
}
});
};
</script>
설명이 약간 분명하지 않습니다. 이해하기 쉽도록 수정할 수 있습니까? 아마도 총알 점을 사용하십시오. – Alex
비디오를 추가하겠습니까? –