CodeIgniter Forums
Simple Ajax paging with existing pagination lib & jQuery - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: Simple Ajax paging with existing pagination lib & jQuery (/thread-20443.html)

Pages: 1 2


Simple Ajax paging with existing pagination lib & jQuery - El Forum - 02-07-2010

[eluser]coma[/eluser]
Hi Berserk, thankx for sharing, i got a problem using your code, i have added all your code above and it appears an error in the Pagination.php, here the error at line #3, it says that undefine variable: paging_function and maybe there is something wrong or you forgot to tell us about the jquery paging function code?

#1 if($this->is_ajax_paging == TRUE)
#2 {
#3 $paging_function = 'onclick="java+script:'.$paging_function.'();return false;"';
$4}
#5 else{
#6 $paging_function = '';
#7 }

Thankx,


Simple Ajax paging with existing pagination lib & jQuery - El Forum - 03-28-2011

[eluser]redraw[/eluser]
where do i put this code
[code]
ajax_paging = function(){
$("p.pagination a").click(function() {
$.ajax({
type: "GET",
url: $(this).get(),
success: function(html){
$("#display-content").html(html);
}
});
});
return false;
};
[/code

and in which file do i call it?

thx


Simple Ajax paging with existing pagination lib & jQuery - El Forum - 02-11-2012

[eluser]Fumigator[/eluser]
[quote author="coma" date="1265570117"]Hi Berserk, thankx for sharing, i got a problem using your code, i have added all your code above and it appears an error in the Pagination.php, here the error at line #3, it says that undefine variable: paging_function and maybe there is something wrong or you forgot to tell us about the jquery paging function code?

#1 if($this->is_ajax_paging == TRUE)
#2 {
#3 $paging_function = 'onclick="java+script:'.$paging_function.'();return false;"';
$4}
#5 else{
#6 $paging_function = '';
#7 }

Thankx,[/quote]

Here's your answer 2 years later Coma! The line should be

Code:
$paging_function = 'onclick="[removed]'.$this->paging_function.'();return false;"';



Simple Ajax paging with existing pagination lib & jQuery - El Forum - 02-11-2012

[eluser]Fumigator[/eluser]
Here's a change I recommend for anyone wanting to get this all working. Instead of using the "onclick" as the OP demonstrates, assign the anchor elements to a class:

Code:
if($this->is_ajax_paging == TRUE)
        {
            $paging_function = ' class="pagecontrol"';
        }
        else{
            $paging_function = '';
        }

You can then use a simple jQuery selector to detect when a paging control anchor is clicked and react to it. Here's mine:

Code:
$('.pagingcontrol').live('click', function()
{
  $.ajax({
  type: "GET",
  url: $(this).get(),
  success: function(html) {
   $('#content_box').html(html);
  }
  });
  return false;
});



Simple Ajax paging with existing pagination lib & jQuery - El Forum - 02-11-2012

[eluser]skunkbad[/eluser]
Community Auth provides an example of using ajax pagination that falls back on standard pagination if javascript is disabled. It also does not require extending the pagination class. The example is located at "Manage Users" when logged in as and Admin or manager. If you just want to see the code, you can check out the manage_users method in the administration controller.


Simple Ajax paging with existing pagination lib & jQuery - El Forum - 08-27-2012

[eluser]Unknown[/eluser]
pls help me to use this code for asynchronous ajax pagination. I want to do pagination without refreshing the page each time