0

I have a page that contains a select element for creating a new object.

When a user visits the page, if he/she selects a value from the select element and then reloads the page (using cmd|ctrl + R) the select keeps the value even though the value was never submitted.

I don't want the option to be remembered upon reloading since it was never submitted.

I tried adding in my application controller a before filter in order to disable cache:

before_filter :disable_cache

def disable_cache
  expires_now
end

Using a browser tool (HttpFox) I get the response header:

Cache-control no-cache, private

and the response body has no selected option in it but while rendering, user's selected option before the reloading of the page is still there.

Response body:

<select class="select optional" id="an_id" name="a_name">
  <option value=""></option>
  <option value="1">a</option>
  <option value="2">b</option>
  <option value="3">c</option>
</select>

An actual reset for the select happens only when using cmd|ctrl + shift + r

Any ideas?

Lazarus Lazaridis
  • 5,803
  • 2
  • 21
  • 35

1 Answers1

0

Workaround: I had to disable autocomplete.

Either on specific element or the the hole form.

I found the solution from here

Community
  • 1
  • 1
Lazarus Lazaridis
  • 5,803
  • 2
  • 21
  • 35