Mlle wrote: > I use javascript to insert a nested model form into a page. If I use > validation on the data entered and it reloads the page with an error > displayed, the nested model form is gone because it's not part of the > original template. > > Is there any way I can change it?
If you need it re-inserted after the page refreshes then you'll have to re-insert it. This is how HTTP works. There is no state that you don't provide yourself. HTTP itself is a stateless protocol. Any notion of state (such as a user session) is all "smoke-and-mirrors" and is why we need such things as the Rails framework in oder to create that "magic." In other words, you'll need to store some state information about what parts need to be added to the rendered template so that you can "replay" those changes later. Any request that does not go through XMLHTTPRequest will loose any information about what was previously rendered. This is why we have a session store, so that state can be maintained between requests and "replayed" during response generation. Or, in your case possibly after response generation. 1. [client] Send request (attach any cookies that might have been stored for this domain) 2. [server] Read params from request 3. [server] Restore state (cookies, session data, etc.) 4. [sever] Generate HTML (or other) response 5. [client] Render HTML response in browser, or deal with whatever response contains 6. [server] Forgets about you and anything to do with this request 7. Goto 1 Think of each XMLHTTPRequest as if it were an invisible "window" that can send requests and get responses in the same manner. From this invisible window you can use JavaScript to directly manipulate the DOM of your visible browser window. This DOM manipulation all happens client-side, which means the server has no knowledge that this happened. As far as the server is concerned it generated, and provided to you, what you ask for, so it "forgets" about you and looks for new requests. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

