title: Rails 4 + Turbolinks + JQuery Turbolinks + Coffeescript: Events being fired multiple times
body: <p>At first, all the javascript bounded are running pretty well.</p>
  <p>However, from the moment I navigate to another page, any event is being fired multiple times. If I refresh the page, everything is back to normal.</p>
  <p>In the jquery.turbolink docs, <a href="https://github.com/kossnocorp/jquery.turbolinks#events-firing-twice-or-more" rel="noreferrer">there is an alert</a> about binding the document events inside a $(function()) block. However, seems like the coffescript works like this by default. So, what should I do?</p>
  <p>This is my environment:</p>
  <p>Gemfile:</p>
  <pre><code>gem 'turbolinks'
  gem 'jquery-turbolinks'
  </code></pre>
  <p>application.js</p>
  <pre><code>//= require jquery
  //= require jquery.turbolinks
  //..app js
  //= require turbolinks
  </code></pre>
  <p>application.html.erb</p>
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;&lt;%= t 'brand' %&gt; &lt;/title&gt;
      &lt;%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' =&gt; true %&gt;
      &lt;%= javascript_include_tag 'application', 'data-turbolinks-track' =&gt; true %&gt;
      &lt;%= yield :head %&gt;
      &lt;%= csrf_meta_tags %&gt;
      &lt;meta name=&quot;description&quot; content=&quot;&lt;%= yield :page_description %&gt;&quot;&gt;
      &lt;meta name=&quot;keywords&quot; content=&quot;&lt;%= yield :page_keywords %&gt;&quot;&gt;
    &lt;/head&gt;
  </code></pre>
  <p>controller.js.coffee</p>
  <pre><code>$(document).ready -&gt;    
    $(document).on 'click', '.addition .label i', (e) -&gt;
      console.log &quot;.addition .label i 'click' fired!&quot;
  </code></pre>
  <p>The thing is, apparently the javascript file generated by coffeescript IS inside a block by default. Check it out:</p>
  <p>controller.js (generated by coffeescript)</p>
  <pre><code>function() {
    $(document).ready(function() {
      $(document).on('click', '.addition .label i', function(e) {
        console.log(&quot;.addition .label i 'click' fired!&quot;);
      });
  ...
  </code></pre>
  <p>So, what should I do to use coffeescript +  JQuery Turbolinks properly?
  Should I make a different configuration?</p>
  <p>Cheers.</p>