remove/add pagination buttons

I have a blog.Few articles inside.Per each article I have a lot of comments that I decide to paginate in group of 5 (let's say..if i have 15 comments i have 3 pagination buttons). I did this by a method of my comment_manager class on pageLoad.

public function pagination($in_art,$perPage)
{
    $per_page=$perPage;
    $count=$this->countComments($in_art);
    $pages = ceil($count/$per_page);

    if($count>=$perPage)
    {
    echo"<div class='pagination'>";
         for($i=1; $i<=$pages; $i++)
        {
            echo "<div class='pag' id='pag_{$i}'>$i</div>";
        }
    echo"</div>";
    }
}

everything is fine. This is how I handle my buttons through JQuery

$(document).ready(function()
{
  [...]//code missing for sake of brevity

  $('#pag_1').css({'color' : '#FF0084'}).css({'border' : 'none'});

  //Pagination Click
  $(".pag").click(function(){

  //CSS Styles
  $(".pag")
  .css({'border' : 'solid #dddddd 1px'})
  .css({'color' : '#0063DC'});

 $(this)
 .css({'color' : '#FF0084'})
 .css({'border' : 'none'});

 //Loading Data
 var data="page="+pageNum+"&id_art="+idArt;
 $.ajax({  
        type: "POST",  
        url: "php/pagination_data.php",  
        data: data,  
        cache: false,  
        success: function(html){  
                                 $('#comments_'+idArt).html(html);  
                               }                                                                        
       });

  });

The point is I need to refresh my pagination buttons after deleting or adding new comments on the fly (dont want the whole page to refresh!).So remove them or add new ones if needed(for example with 16 comments i need one more button) Thanks Luca

Answers


Seems to me that if you want the actual pagination links to be updated on the fly, then you will need to create an AJAX version that returns the current pagination.

For example: When you delete a comment, after the comment gets deleted, run an AJAX call to get what the pagination is now, and update the pagination div's contents.


Need Your Help

Missing keyword error in Oracle

sql oracle alter-table

I am trying to alter a column data type in SQL but it gives me missing keyword error. I have looked at how to change a column in several places and they all gave me this piece of query:

Does Hive support Select in Select?

sql hadoop hql hive

Is the code bellow in Hive possible, wich some change?:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.