title: How do I call a JS function from a different file in the Rails asset pipeline
body: <p>This is probably more a general JS encapsulation issue than Rails asset pipeline.</p>
  
  <p>In the asset pipeline I have some general JS files that are used everywhere:</p>
  
  <p><em>app/assets/javascripts/pickers.js.cofeee</em></p>
  
  <pre><code>jQuery -&gt;
  
    $('.datetimepicker').datetimepicker
      dateFormat: 'yy-mm-dd',
      timeFormat: 'h:mmtt',
      ampm: true,
      hourGrid: 4,
      minuteGrid: 10
  
    $('.datepicker').datepicker
      dateFormat: 'yy-mm-dd'
  </code></pre>
  
  <p>I also target body classes to run specific JS on controller/action specific pages:</p>
  
  <p><em>app/assets/javascripts/employees.js.cofeee</em></p>
  
  <pre><code>jQuery -&gt;
  
    if $('.employees.edit').length
  
      # initialize datepickers when adding new nested fields
      $('form').live 'nested:fieldAdded', (e) -&gt;
        $(e.field).find('.datepicker').removeClass('hasDatepicker').datepicker
          dateFormat: 'yy-mm-dd'
  </code></pre>
  
  <p>Now this isn't the most cumbersome example of repetition but hypothetically if I wanted to move this datepicker code into a function and then call it in the employees.js.coffee file, how could I do that?</p>