I have a ajax form creating by “form_remote_for”, whose url is to
create a new model by default. The page doesn’t change after the ajax
call on submit button so the form is still there after the new model
is created. But if I submit the form for the second time, I want to
update the formerly created model using an Ajax post.
I think I could render an rjs at the end of the first submit action
and the rjs should change the onsubmit event handler of the form, say:
page[:form][:onsubmit] = article_path(@article)
but it seems that this doesn’t work. Another problem is that
“article_path(@article)” will generate something like “/article/12”
with HTTP PUT method, but I need something like “new
Ajax.Request(…)”. Any idea about these two questions? Thanks.