On 8 June 2010 20:45, Steve Russo <li...@ruby-forum.com> wrote:
> Colin Law wrote:
>> On 8 June 2010 18:40, Steve Russo <li...@ruby-forum.com> wrote:
>>> sure why. �If I do a simple reload/refresh on the browser, the values
>>> within the partials are preserved, but not when a validation error
>>> occurs.
>>>
>>> Any thoughts on what the validation may be doing that clears the dynamic
>>> partial? Do you think the validation errors cause a re-rendering of the
>>> partials even though a page reload/refresh does not?
>>
>> When a validation error occurs and you re-display the page, are you
>> setting whatever data is needed so that the correct div shows?
>
> It seems that the correct div is being displayed after the error is
> reported. Although the values are blank. However, the code used to set
> the div visibility isn't called though, based on the break point I set
> not breaking on that line whenever a validation error occurs. It seems
> as though the page just re-displays what divs are already present. Even
> so, if the code block above did run, all it does is show or hide the
> div. The partials are only rendered when the page is first loaded.

When you re-render after a validation error that is a 'first loading'
of that page.  The fact that you happen to be rendering the same page
again is irrelevant.  Are you saying that the divs are empty?  If so
have a look at the code you use to generate the view in the first
place, presumably this is from controller new or edit or something.
Now look at where the validation failure is, in create or update
possibly, when save fails.  Are you setting everything up properly in
that case?

> Also,
> all of the other static form fields preserve their values after the
> error detection.

That is because the object you are displaying is loaded into
@something in create or update, and will be passed on to the view.

> Not sure why these rendered partials would be any
> different. The JS code only shows or hides their respective DIVs.

I guess that the partials are not being rendered following save
failure in create or update, as I suggested earlier.

If you still can't work it out use ruby debug to break into the code
where the partials should be called and find out why they are not.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to