will_paginate with jquery ajax / постаничный вывод в Rails с will_paginate и Jquery


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //ajax function-------------------------------------
  2.  
  3. function ajax_will_paginate(s){
  4. $.ajax({
  5. type: "POST",
  6. url: "index/blog_paginate?page="+s,
  7. success: function(msg){
  8. $("div.blog[style='display: block;']").html(msg);
  9. replace_paginate_links();
  10. }
  11. });
  12. }
  13.  
  14. // replace links function---------------------------
  15.  
  16. function replace_paginate_links(){
  17. $('div.pagination a').each(function(){
  18. var new_attr = "ajax_will_paginate"
  19. var get_href_a = $(this).attr('href').split('=');
  20. var get_href = get_href_a[get_href_a.length-1]
  21.  
  22. $(this).attr('href',"#")
  23. $(this).attr('onclick',"ajax_will_paginate('"+get_href+"'); return false;")
  24. })
  25. }
  26.  
  27. $(document).ready(function(){
  28. replace_paginate_links()
  29. })

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.