title: Disabling and Reenabling Form Submit with JQuery in Rails
body: <p>I have a form that allows users to leave a comment.  Here is my submit action:</p>
  
  <pre><code> &lt;%= semantic_form_for([@project, step, step.comment_threads.build]) do |f| %&gt;
      &lt;%= f.text_area :body %&gt;
      &lt;%= f.actions do %&gt;
           &lt;%= f.action :submit, :label=&gt;"Comment", :button_html =&gt; {:class=&gt; "btn btn-small btn-primary commentSubmit", :disable_with =&gt; "Comment"} %&gt;
      &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I disable the form submit if the user tries to submit an empty comment.  But I can't get it to be re-enabled after the user enters text in the comment box. (When I click the comment button, the form doesn't get submitted). This is my javascript:</p>
  
  <pre><code>$('.commentSubmit').click(function(){
    var comment = $(this).parents('form').children('.field').find('textarea').val();
    console.log('comment: ' + comment);
    if(comment.length == 0){
      alert('Cannot post an empty comment');
      $(this).parents('form').submit(false);
    }else{
      console.log('submitting form');
      $(this).parents('form').submit();
    }     
  
  });
  </code></pre>