stopping accidental form submissions


I'm using rails 3 and have an ajax form where users can add data,
click submit, and it will be appended to a feed. The problem is if the
users click submit (or press enter) multiple times, the form seems to
be submitted multiple times as well resulting in the same item showing
in the feed multiple times.

this is what my form tag looks like:
<% form_for, :remote=>true, :loading=>"Form.Element.disable('commit')", :complete=>"Form.Element.enable('commit')"
do |f| %>


    <%= f.submit 'Create', :id => "commit" %>

as you can see i've tried to disable the submit button. however the
javascript code does not get generated.

Would very much appreciate some help with this.


I don't see anything there that will disable the button after it is
clicked. Have a look at the disable_with option on f.submit.