For a regular form I use the :onlick option to disable the submit button
after the first click in order to prevent double clicks (leading to
double entries):
This controller method ‘enter_payment’ for this ajax form creates an
object and re-renders a couple partials. With this code, the object is
created, but the following error comes up when it tries to render the
partials:
“Can only render or redirect once per action”
When I comment one of the partials out, it redirects to the other
partial instead of re-rendering it within the original page. How might I
be able to fix this?
prevents the trouble for non-ajax by simply returning and never reaching
the render calls
make something like logger.info(“foo”) to see, if it reaches the lines
at all
anyway, the error message is right, since two render calls are not
allowed
and if the partials do not contain rjs, that will fail and render the
whole partial as a page. one reason, there’s nowhere any information,
which html-tag to replace or use as target
Here’s the controller code. It works fine without the onclick option in
the submit button (renders the partials without reloading the page). I’m
guessing the submit method I’m using in the :onclick option is expecting
a redirect. That would explain it redirecting me to a partial and it
failing when it gets multiple redirect commands. I’m pretty javascript
retarded though. I just hack what I see and hope it works
def input @person = Person.find(params[:id])
name = (params[:name])
if @person.update_attributes(params[:person])
event = Event.create(:person_id => @person.id, :name => name,
:date => Time.now) @new_event = event
return if request.xhr?
render :partial => ‘events’
render :partial => ‘inputs’
end
end
Thanks for the ideas. I get a different, but still incorrect result when
I submit to a method with inline rjs like you’re suggesting. It
redirects the browser to the controller method but, instead of rendering
the partial, it renders code for the javascript instructions.
Thanks for the ideas. I get a different, but still incorrect result when
I submit to a method with inline rjs like you’re suggesting. It
redirects the browser to the controller method but, instead of rendering
the partial, it renders code for the javascript instructions.
that one…
somehow it’s loosing the information, that’s an ajax call and handles
the returned text as html
i had some trouble with remote forms and manually calling submit, maybe
you can hack around it with calling onsubmit instead
or test it with link_to_remote, until you get working code, without
additional trouble of form-submit
and remember, not to use :update =>, but your code:
<% form_remote_tag :url => {:action => ‘enter_payment’} do %>
in the view