0

I have the following code to generate randomly from the server some random value and put it both on the web page, and in a text area:

import random
@app.route("/mock_template")
def mock_template():
    x = random.uniform(0,1)
    return render_template("mock_template.html",x=x)

And the file "mock_template.html" contains:

{{x}}

<textarea> {{x}} </textarea>

If I go to this page, I would get some value for x, like 0.1234, both in the page and in the editable zone, which is fine. However, if I write something in the editable zone, and then refresh, the value on the page has changed (as expected), but the value in the editable zone is still 0.1234.

I understand that this behavior can be desirable if I don't want the user to lose what she has started to write before an accidental refresh, but in my case I want the new value of x to be displayed. How do I do that? (I don't care of losing the text the user has entered).

S4M
  • 4,561
  • 6
  • 37
  • 47
  • 2
    Are you sure this is related to Flask? Check [this](http://stackoverflow.com/questions/4263536/firefox-cache-textarea-value). – dilbert May 24 '14 at 11:48
  • @dilbert indeed. I set `autocomplete` to `off` as mentionned in the question you linked, and that solved it. You can put this as an answer so I will be able to close the question. – S4M May 24 '14 at 11:50
  • This issue isn't related to Flask. It's highly likely to be caused by your browser. If you're using Firefox, refer to [this answer](http://stackoverflow.com/questions/4263536/firefox-cache-textarea-value). – dilbert May 24 '14 at 11:53

0 Answers0