title: Dynamically adding attributes to elements based on a selector in jQuery
body: <p>I'm stuck with some jQuery-based library which is forcing me to add an attribute to a lot of elements in my markup in order for it to "unobtrusively" do some AJAX posting of forms for me, as if they haven't yet looked in a dictionary to read up on what "unobtrusive" actually means.</p>
  
  <p>After trying to poke at said library from the outside to change the selector it was using, I gave up on that and am now trying to use jQuery to add the attribute so that I can make it actually-unobtrusive.</p>
  
  <p>If I do this:</p>
  
  <pre><code>$('form.filter, .pagination a, .sortable a').attr('data-remote', true);
  </code></pre>
  
  <p>This fixes every element at the time of execution. The problem is that the AJAX queries replace sections of the page which then contain more elements which should have the attribute added. So I'm finding that the first click works, but the second loads the page without using AJAX, at which point the cycle repeats because the whole document has been loaded again.</p>
  
  <p>I vaguely gather that <code>on()</code> is for this sort of thing, but I have tried multiple ways of using it and none of them have fired yet (I have an <code>alert</code> in there so that I would find out when it does.)</p>
  
  <p>What is the proper way to do this?</p>