# Rails, Ajax, and the back button

**URL:** <https://www.ruby-forum.com/t/rails-ajax-and-the-back-button/92849>\
**Category:** Rails\
**Created:** [April 25, 2007, 12:24am UTC](https://www.ruby-forum.com/t/rails-ajax-and-the-back-button/92849 "2007-04-25T00:24:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![desertpenguin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d07c76/32.png) [@desertpenguin](https://www.ruby-forum.com/u/desertpenguin)\
**Post date:** [April 25, 2007, 12:24am UTC](https://www.ruby-forum.com/t/rails-ajax-and-the-back-button/92849/1 "2007-04-25T00:24:28Z")

</div>

When I go back to a page with a form, the text field fails to retain a  
value. It was created with text\_field\_with\_auto\_complete. I want it to  
retain the value entered previously.

Thanks in advance for any help…

Details:

I have a form created with  
\<% form\_for :quote, :url =\> { :action =\> :myaction} do |form|%\>

within the form I have an ajax field for another model

\<% fields\_for :classification do |classification| %\>

 Classification: \<%= text\_field\_with\_auto\_complete :classification, :class\_desc , :skip\_style =\> true, :size =\> 60 %\> \<% end %\>

Unfortunately, this field gets reset with the back button.

Thanks again for any help - it is driving me nuts

---

<div class="post-metadata">

**Author:** ![desertpenguin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/d07c76/32.png) [@desertpenguin](https://www.ruby-forum.com/u/desertpenguin)\
**Post date:** [April 25, 2007, 2:00am UTC](https://www.ruby-forum.com/t/rails-ajax-and-the-back-button/92849/2 "2007-04-25T02:00:21Z")

</div>

Desert P. wrote:

> When I go back to a page with a form, the text field fails to retain a  
> value. It was created with text\_field\_with\_auto\_complete. I want it to  
> retain the value entered previously.
> 
> Thanks in advance for any help…
> 
> Details:
> 
> I have a form created with  
> \<% form\_for :quote, :url =\> { :action =\> :myaction} do |form|%\>
> 
> within the form I have an ajax field for another model
> 
> \<% fields\_for :classification do |classification| %\>
> 
> Classification: \<%= text\_field\_with\_auto\_complete :classification, :class\_desc , :skip\_style =\> true, :size =\> 60 %\> \<% end %\>
> 
> Unfortunately, this field gets reset with the back button.
> 
> Thanks again for any help - it is driving me nuts

If you look at the HTML source generated, does the input field have a  
tag

autocomplete=“off”

I think that may be your problem. Try to see how you can get rid of  
that.

Stephan
