-
-
Save rombyar/e16318d96102d3395568c674f19f0bb3 to your computer and use it in GitHub Desktop.
Load scroll dengan codeigniter, js->controller->model->view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function auto_halaman($num) | |
{ | |
$data['anime_data'] = $this->anime_panel_model->mengambil_data2($num); //ini untuk menload data posting nya | |
$this->load->view('browse/front/anime_view', $data); // ini untuk ke view nya | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ini adlah view yang nanti menampung content load | |
<div class="anime-slide"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ini view yang nanti kan di tampilkan saat di scroll ini contoh punya ane | |
<?php | |
foreach ($anime_data as $anime_content): | |
?> | |
<div class="anime-slide-content" | |
style="background: url(<?php echo $anime_content->ad_thumb_img;?>); | |
background-size: cover;"> | |
<div class="anime-content-hover"> | |
<div class="anime-detil-pendek"> | |
<div class="anime-content-score tipe-font kotak-kecil"> | |
20% | |
</div> | |
<div class="anime-content-tipe tipe-font kotak-kecil"> | |
<?php echo $anime_content->ad_type;?> | |
</div> | |
<div class="anime-content-populer tipe-font kotak-kecil"> | |
1051 | |
</div> | |
</div> | |
<!-- Judul --> | |
<div class="anime-content-title"> | |
<a href="<?php echo base_url().'browse/anime_page/anime/'.$anime_content->ad_slug;?>"> | |
<div class="title"><?php echo $anime_content->anc_ad_title;?></div> | |
</a> | |
</div> | |
<!-- Judul Berakhir --> | |
</div> | |
</div> | |
<?php endforeach;?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* load otomatis data anime | |
* taro js atau load js pada view halaman_utama.php | |
*/ | |
var Hal = 0; // halaman dari 0 | |
$(window).scroll(function() { | |
if($(window).scrollTop() + $(window).height() == $(document).height()) | |
{ | |
Hal += 16; // ini ditambah 16 karena yg ane pakek memuat 16 posting sekali load bisa di ganti sesuai kebutuhan | |
$.get('<?php echo base_url();?>isi dengan controller tujuan/'+Hal, function(data) | |
{ | |
$('div.anime-slide').append(data); | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mengambil_data2($num) | |
{ | |
$sql = "SELECT * FROM anc_anime_data ORDER BY anc_ad_id DESC LIMIT $num, 8"; | |
$result = $this->db->query($sql)->result(); | |
return $result; | |
//$num itu page nya, 8 itu adalah jumlah yang akan keluar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment