简体   繁体   English

如何保持浏览器上的表单条件前进和后退按钮单击

[英]How to keep the form condition on browser go back and go forward button click

I am using grails 2.4.2 version which uses HTML 5. I have some form element based on some condition. 我正在使用使用HTML 5的grails 2.4.2版本。我有一些基于某些条件的表单元素。 Such as District, Thana. 如塔那区。 When I select the district then I am hiding thana and when selecting thana then hiding district. 当我选择区域时,我将隐藏该区域;而当选择该区域时,则将其隐藏区域。 it work fine. 它工作正常。 But when I click the go back button of the browser then it shows both the field. 但是,当我单击浏览器的“返回”按钮时,它将同时显示两个字段。 I want to keep the form element condition as I expected when a user click the go back button of the browser. 我想保持表单元素条件与用户单击浏览器的“返回”按钮时所期望的一样。 I have no idea how to implement it. 我不知道如何实现它。 Can anyone please help me on this? 有人可以帮我吗?

将所有字段存储在会话的localStorage中,然后在加载页面时,使用JavaScript从localStorage加载所有内容。

  1. save state when location changed 位置更改时保存状态
  2. use state when page loaded 页面加载时的使用状态

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM