I know it''s unlikely that anyone will check this link, but here''s hoping http://stackoverflow.com/questions/10051050/ajax-form-using-simple-form-with-preserved-error-validation Sorry, too hard to explain without showing the pics. Abram -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Abram
2012-Apr-07 21:17 UTC
Re: AJAX form (using simple_form) with preserved error validation
Someone provided an answer. FYI I think you can simplify this by putting your form in a partial (we''ll call it simple_form), and putting this code in reload.js.erb: $("#entryform").html("<%= escape_javascript(render :partial => ''simple_form'') %>"); I''m not familiar with jQuery''s load method, but I assume it does a second request. The key with rendering errors is the instance variable (@brand) you''re using while rendering the form has to be the same one you tried to save in create, so you can check the errors on it. This is why you always use render instead of redirect_to when you want to render errors. If you do a redirect, you start a new request, meaning @brand is reinitialized. I''m assuming your $(...).load(...) is having the same issue. On Sat, Apr 7, 2012 at 2:01 PM, Abram <funkdified-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I know it''s unlikely that anyone will check this link, but here''s hoping > > http://stackoverflow.com/questions/10051050/ajax-form-using-simple-form-with-preserved-error-validation > > Sorry, too hard to explain without showing the pics. > > Abram-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.