Search code examples
jqueryruby-on-railsruby-on-rails-3ujs

Converting form_remote_tag to form_for for Rails 3 UJS


I'm trying to convert this for Rails 3

<%= form_remote_tag :url => feedback_url, 
  :update    => 'flash_message', 
  :before    => "doSomething()", 
  :condition => "condition()", 
  :complete  => "doSomethingElse();" -%>

Here's what I have so far

<%= form_tag feedback_url, :remote => true, :id => 'form' do %>
  <%# Gather data %>
<% end -%>
<script>
    $(function() { 
      $("#form").bind("ajax:beforeSend", function() {
          doSomething();   
        }).bind("ajax:success", function() {
          doSmomethingElse();
        });
      });   
    });
</script> 

Solution

  • I found this post for you. I am sure that you will solve https://web.archive.org/web/20201109001755/https://www.alfajango.com/blog/rails-3-remote-links-and-forms/