title: How to render different UJS actions based on the click event in Rails 4 with jQuery
body: <p>I have a div and need to render different .js.erb actions based on the <code>clickevent</code> <strong>on that div</strong>.
  For example: </p>
  
  <ul>
  <li>on <code>dblClick</code>, I want to render the new.js.erb</li>
  <li>on <code>click</code>, I want to render show.js.erb</li>
  </ul>
  
  <p>In my asset/javascripts directory I have a <strong>file.js.coffee</strong>:</p>
  
  <pre><code>$('#myDiv').on "dblclick" -&gt;
    $.getScript('/projects/xy/plan/new')
  </code></pre>
  
  <p>This basically works. It shows the modal in my <strong>new.js.erb</strong>:</p>
  
  <pre><code>$("#myModal").modal("show");
  </code></pre>
  
  <p>How can I make the <code>$.getScript</code> URL dynamic and include an object for the show and edit action?</p>
  
  <p><strong>Edit:</strong>
  Rich Pecks answer seems to be correct.
  Because of simplicity I just wrote <code>$('#myDiv').on "dblclick"</code>.
  The full example is:</p>
  
  <pre><code>  $zoomcontainer = $("section").find(".parent")
    $panzoom = $zoomcontainer.find(".panzoom").panzoom(
      $zoomIn: $zoomcontainer.find(".zoom-in")
      $zoomOut: $zoomcontainer.find(".zoom-out")
      $zoomRange: $zoomcontainer.find(".zoom-range")
      $reset: $zoomcontainer.find(".reset")
    ).on("dblclick", (e) -&gt;
  </code></pre>
  
  <p>How should I put my data attributes in the HTML?</p>
  
  <p>This is my basic HTML structure:</p>
  
  <pre><code>&lt;section&gt;
    &lt;div class="parent" data-project_id="&lt;%= @project.id %&gt;" data-plan_id="&lt;%= @plan.id %&gt;"&gt;
      &lt;input type="range" class="zoom-range" /&gt;
      &lt;div id="plan" class="panzoom" style="background: url('&lt;%= @plan.asset.url %&gt;') no-repeat;&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>