ajax pagination links


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

tag links with .click function


Copy this code and paste it in your HTML
  1. ## view:
  2.  
  3. .pagination
  4. =will_paginate @photos, :class => 'digg_pagination'
  5.  
  6.  
  7. ## application.js
  8.  
  9. document.observe("dom:loaded", function() {
  10. ajax_pagination()
  11. })
  12.  
  13. // ajax pagination links
  14. var ajax_pagination = function () {
  15. var container = $(document.body)
  16. container.observe('click', function(e) {
  17. var el = e.element()
  18. if (el.match('.digg_pagination a')) {
  19. new Ajax.Request(el.href, { method: 'get' })
  20. e.stop()
  21. }
  22. })
  23. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.