Jump to content

Recommended Posts

Posted

Já tinha experimentado esse plugin, mas não consegui meter a funcionar a 100%.

Fica sempre a adicionar dados, enquanto eu na base de dados só tenho 21 linhas.

Na view tenho:

<!-- Start twelvecol -->
<div class="twelvecol items-list last">
 <?php
 foreach ($query->result() as $i)
 {
 ?>
  <div class="box">
   <img src="<?php echo base_url().$i->image; ?>" alt="<?php echo $i->name; ?>">

   <div>

	<div class="name-item"><h2><?php echo $i->name; ?></h2></div>

	<div class="view-item"><a href="<?php echo base_url().'item/'.$i->url_friendly; ?>"><img src="<?php echo base_url().'url...'; ?>" alt="View item"></a></div>
   </div>

  </div>
 <?php

 }
 echo $this->pagination->create_links();
 ?>

</div>
<!-- Twelvecol end -->
 

Controller

$this->load->library('pagination');
 $config['base_url'] = 'http://localhost/project/page/';
 $config['total_rows'] = $this->db->get('table')->num_rows();
 $config['per_page'] = 12;
 $config['full_tag_open'] = '<div id="pagination">';
 $config['full_tag_close'] = '</div>';

 $this->pagination->initialize($config);
 $data['query'] = $this->db->get('table', $config['per_page'], $this->uri->segment(3));
 
 <script>
  $(document).ready(function() {
 // the items you will be loading more of
 $('.items-list').infinitescroll({

   navSelector  : "#pagination",		  
				  // selector for the paged navigation (it will be hidden)
   nextSelector : "#pagination a:first",  
				  // selector for the NEXT link (to page 2)
   itemSelector : ".items-list"		
				  // selector for all items you'll retrieve
 });
  });
 </script>
Posted

Omitiste a parte mais importante, os links da paginação.

Afixa aqui o código html da paginaçã, gerado pelo codeigniter.

A não ser que tenhas mudado ou extendido a classe de paginação do code igniter, o selector do link está mal. O link para a próxim página não é o primeiro.

adicionalmente, não sei se um selector por class não te devolver sempre um array, mas isso é questão de experimentares. Abre a consola do chrome ou do firebug e escreva lá

$(".items-list")

e vê se isso seleciona alguma coisa.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.