Search code examples
jqueryruby-on-rails-3ruby-on-rails-3.1ruby-on-rails-3.2

rails 3 how do i submit a remote form with jquery and avoid callbacks


I have a remote => true form and would like to submit it AND avoid a submit method.

Usually i would do

form$.get(0).submit()

form$.submit(function(){..avoid going here..})

but this sends the form as html instead of js. Any way to do this and get js in response?

Thanks!


Solution

  • man that i was a pain to find.

    the answer is replace

    $(form).get(0).submit()
    
    $(form)[0].submit()
    

    by

    $(form).trigger("submit.rails")
    

    this will skip all submit even listeners except the rails one.