title: How to attach event dynamically in javascript?
body: <p>I am trying overwrite links (transform in ajax links) but when I try to add an event to a tag nothing happens.</p>
  
  <p>My script.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $j(document).ready(function() {
          $j(".will_paginate_styles a").each(function() {
              if (this.innerText.length &gt; 1) {
                  this.style.padding = "8px 6px 10px 6px";
                  var url = this.href + "&amp;category_id=&lt;%= 1 %&gt;";
                  this.href = "#";
                  jQuery(this).live("click",
                       function(){
                                  new Ajax.Request(url, {asynchronous:true, evalScripts:true, parameters:'authenticity_token=' + encodeURIComponent('uurmOp9OrgS1CRpcpKdMN9PHlMTt+lkHjhYdNgP+LbQ=')}); return false;
                                 }
                  );
              }
  
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>How could I attach a event to this tag or transform the link to ajax link? Any suggestions?</p>