Advertisement
Guest User

Untitled

a guest
Aug 5th, 2012
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function do_links(links) {
  2.   for (var i = 0, n = links.length; i < n; ++i) {
  3.     link_prepare(links[i]);
  4.   }
  5. }
  6.  
  7. function link_prepare(link) {
  8.   if (link.prepared) return;
  9.  
  10.   $(link).observe('click', function (e) {
  11.     var dasLink = Event.findElement(e);
  12.     console.log('Link', link); // si tu as toujours le même lien = problème de closure :P
  13.     new Ajax.Updater('dMain', link.href, {
  14.       onComplete: function(response) {
  15.         // Handle the response content...
  16.         do_links($('dMain').select('a'));
  17.       }
  18.     });
  19.     e.stop(); // == return false sur le onclick();
  20.   });
  21.  
  22.   link.prepared = true;
  23. }
  24.  
  25. function my_onload() {
  26.   do_links($$('a'));
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement