I’m using a remote form to submit comments in Rails. The user should not be sent to a new page because I’m using this remote form.
When I hit “submit” I’d like it to have a status fade in that says “Thanks for submitting” and the form clear. Yet, I can’t figure out how to do this for the life of me.
The problem comes in that when I do $(‘form’).submit -> and then clear the text area, it resets it before I actually finish the submit, so I get a blank submission in Rails.
I’m using Rails 3.2, Coffeescript and Jquery.
Maybe you are wanting to do this as the form is submitted but… you use jQuery’s bind (or live) method and wait for it to return success.
If you want to do it regardless of success, or in whatever stage of the request check out the other available ajax callbacks ‘beforeSend’, ‘complete’, ‘error’, etc.