Welcome Guest, Not a member yet? Register   Sign In
Simple Ajax paging with existing pagination lib & jQuery
#11

[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,
#12

[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
#13

[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;"';
#14

[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;
});
#15

[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.
#16

[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




Theme © iAndrew 2016 - Forum software by © MyBB