I have a form which has remote => true. When i submit it the first time everything works well.
If there are any errors i want to add new fields to this form. I did this with update.js.erb.
The problem is that when i resubmit this form, the result js file is rendered as html (ie i see the js file text on the screen). This is the same update.js.erb file that was rendered as js the first time…
Any idea what i’m missing?
UPDATE:
On the first try, format is:
format
=> #<ActionController::MimeResponds::Collector:0xc61711c
@order=[text/javascript],
@responses={text/javascript=>nil}>
On the second submit it’s:
format
=> #<ActionController::MimeResponds::Collector:0xceaadec
@order=[],
@responses={}>
my update.js is just basically
$("#checkout_modal").html("<%= escape_javascript(render 'plan_pay_modal')%>");
and plan_pay_modal is the same partial as on the original page (a form which will show new fields if there are errors. I also tried just the fields same problem).
turns out the problem was that i was submitting through jquery
does not work in this case… To get working i had to use
rails 3 how do i submit a remote form with jquery and avoid callbacks