title: Using jQuery File Upload with Rails
body: <p>I followed the Railscasts episode (<a href="http://railscasts.com/episodes/381-jquery-file-upload" rel="nofollow">http://railscasts.com/episodes/381-jquery-file-upload</a>) to get file uploads working on my site. Everything works the way the tutorial intended, but i'd like to change up one thing and haven't been successful thus far.</p>
  
  <p>I'd like to form to NOT submit until after they've clicked a submit button. Right now, and I believe with the following js, the form submits when a user finds a file.</p>
  
  <pre><code>#Snippet
  data.submit()
  
  
  #Whole JS File
  jQuery -&gt;
    $('#new_update').fileupload
      dataType: "script"
      add: (e, data) -&gt;
        types = /(\.|\/)(gif|jpe?g|png)$/i
        file = data.files[0]
        if types.test(file.type) || types.test(file.name)
          data.context = $(tmpl("template-upload", file))
          $('#new_update').append(data.context)
          data.submit()
        else
          alert("#{file.name} is not a gif, jpeg, or png image file")
      progress: (e, data) -&gt;
        if data.context
          progress = parseInt(data.loaded / data.total * 100, 10)
          data.context.find('.bar').css('width', progress + '%')
  </code></pre>
  
  <p>I'd prefer to remove this and use a button instead because I have a textarea that I want the user to fill out before submitting the form. </p>
  
  <p>How can I pause image upload until after the user clicks a button???</p>
  
  <p><strong>Update</strong></p>
  
  <p>Full JS file</p>
  
  <pre><code>jQuery -&gt;
    $('#new_update').fileupload
      dataType: "script"
      add: (e, data) -&gt;
        types = /(\.|\/)(gif|jpe?g|png)$/i
        file = data.files[0]
        if types.test(file.type) || types.test(file.name)
          data.context = $(tmpl("template-upload", file))
          $('#new_update').append(data.context)
        else
          alert("#{file.name} is not a gif, jpeg, or png image file")
  
        $("#submt_button").on 'click', -&gt;
          data.submit()
  
      progress: (e, data) -&gt;
        if data.context
          progress = parseInt(data.loaded / data.total * 100, 10)
          data.context.find('.bar').css('width', progress + '%')
  </code></pre>