title: What is the best way to organize unobtrusive JavaScript across multiple pages?
body: <p>I love jQuery but am running into a problem with larger site and multiple pages.  My problem is that each page has unique requirements and I need to know the best way to tell jQuery which pages to activate certain things.  For example, some forms need the <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">Validator plug-in</a> and some don't, some tables use <a href="http://datatables.net/index" rel="nofollow noreferrer">DataTables plug-in</a> and some don't, etc.</p>
  
  <p>Now I guess I could build complex logic (switch statements) into my application JavaScript file that fire different actions depending on what page they are on, but that just seems smelly.  What is the Best Practice here?</p>
  
  <p><strong>UPDATE:</strong> There have been lots of good ideas on this question but not quite what I'm looking for.  Let me rephrase the question in a more general way. </p>
  
  <p>Currently I am using Rails and its Prototype helpers to build my AJAX components, but I want to move to UJS. How do I tell jQuery which links/buttons to make AJAX and which to avoid? And, given that I can differentiate the that are supposed to have AJAX, how do I give each link its own parameters (method, update, etc.) like I could with the helpers?</p>
  
  <p>I mean besides building a huge page of specific jQuery selectors targeting each individual link/button. :)</p>