title: Using simple javascript and passing arguments with Rails3 and UJS
body: <p>I have watched railscasts about unobtrusive javascript and read numerous tutorials, but two things about unobtrusive javascript in Rails3 still confuses me:</p>
  
  <ol>
  <li>End-point for simple javascript (hiding some elements, adding CSS class, ...)</li>
  <li>Passing arguments to JS</li>
  </ol>
  
  <p>Let me clarify this with sample code. I want to make a link which fades out some element with id "sample":</p>
  
  <pre><code>link_to 'Fade sample', url, :remote =&gt; true
  </code></pre>
  
  <p>What should be the url so it can execute JS? Should it be new action in controller named for example 'javascript' so it can access JS in javascript.js.erb which contains:</p>
  
  <pre><code>$('#sample').fadeOut();
  </code></pre>
  
  <p>Also, second question about ujs is related with passing arguments to JS (timeout, for this example). I can write:</p>
  
  <pre><code>link_to 'Fade sample', url, :data-timeout =&gt; 1500, :remote =&gt; true
  </code></pre>
  
  <p>but don't know how to access data-timeout in javascript.</p>
  
  <p>I am using Rails 3.0.5, JQuery 1.5.2 and jquery-ujs.</p>