在后退按钮清除表单

在后退按钮清除表单

本文介绍了在后退按钮清除表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个页面与一个窗体中的几个复选框,选中时,用jquery从表中过滤相应的信息。我的问题是以下情况:


  1. 有人检查一个或多个框,从表中隐藏行

    >
  2. 他们点击链接,转到另一页



此时,复选框仍处于选中状态(至少为chrome),但所有表行

解决方案

如果您的目标是让他们回到他们离开前的确切视图(表格行仍然隐藏):



这是一个缺点



您需要做的是将应用程序状态存储在URL哈希中标签,以便当用户使用他们的后退按钮,您可以检索状态并重建其视图。



这是另一个问题的答案可能会帮助你:



如果您的目标是将网页恢复其初始状态:



页面加载的复选框:

  $('input:checkbox')。 

- 或 -



重置整个形式:

  $(':input','#myform')
.not submit,:reset,:hidden')
.val('')
.prop('checked',false)


I have a page with several check-boxes in a form, which when selected, filter corresponding info out of a table with jquery. My problem is the following scenario:

  1. Someone checks one or more boxes, hiding rows from table

  2. They Click a link, going to another page

  3. They click the back button.

At this point, the check boxes are still checked (in chrome at least), but the all the table rows are visable again.

Any Ideas?

解决方案

If your objective is to bring them back to the exact view they had before they left (table rows are still hidden):

Such is a disadvantage (or advantage) of a website: it's stateless, particularly when it comes to client-side manipulation.

What you'll need to do is store the application state in the URL hash tag so that when the user uses their back button, you can retrieve the "state" and reconstruct their view.

Here's another question whose answer might help you: jquery javascript: adding browser history back with hashtag?

If your objective is to return the page back to its initial state:

Just reset all the checkboxes on page load:

$('input:checkbox').prop('checked', false);

-or-

Reset the entire form:

$(':input','#myform')
 .not(':button, :submit, :reset, :hidden')
 .val('')
 .prop('checked', false)
 .prop('selected', false);

这篇关于在后退按钮清除表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:43