rjsma Posted February 16, 2013 at 10:11 AM Report #495531 Posted February 16, 2013 at 10:11 AM Boas, Alguém tem alguma noção de fazer o infinite scroll( ligado a base de dados ) juntamente com o codeigniter? Cumprimentos 😉
HappyHippyHippo Posted February 16, 2013 at 10:13 AM Report #495532 Posted February 16, 2013 at 10:13 AM sabes javascript ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
rjsma Posted February 16, 2013 at 10:30 AM Author Report #495534 Posted February 16, 2013 at 10:30 AM Tenho alguma noção, mas foi uma coisa que não aprofundei muito.
pedrotuga Posted February 16, 2013 at 11:10 AM Report #495535 Posted February 16, 2013 at 11:10 AM Faz a tua página com paginação normalmente, depois usa este plugin jquery: http://www.infinite-scroll.com/ só precisas de tuas ou três linhas de código. Funciona na perfeição.
rjsma Posted February 16, 2013 at 03:17 PM Author Report #495558 Posted February 16, 2013 at 03:17 PM 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>
pedrotuga Posted February 17, 2013 at 10:20 PM Report #495892 Posted February 17, 2013 at 10:20 PM 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now