简体   繁体   English

标签内容:显示页面加载时的最新标签

[英]Tabbed Content: Show latest tab on page load

i have a basic tabbed content showing forms in each. 我有一个基本的选项卡式内容,分别显示了表格。 example of my site below. 下面是我的网站的示例。 在此处输入图片说明

user submits form, and when page reloads it shows the default first tab. 用户提交表单,并在页面重新加载时显示默认的第一个标签。 has anyone found a solution for this? 有没有人找到解决方案? the goal if i am on third tab for example, and i hit submit form in that tab, when page reloads it loads the third tab instead of first one? 目标,例如,如果我在第三个选项卡上,并且在该选项卡中命中了提交表单,则在页面重新加载时会加载第三个选项卡而不是第一个选项卡?

i am sure i could write some hacky javascript such as: 我确信我可以写一些hacky javascript,例如:

if form submit
check what tab ID form was submitted
force tab open on page load

but i have a feeling in 2017 we have came up with a better solution for this type of instance. 但我有一种感觉,在2017年,我们为此类实例提出了更好的解决方案。 i appreciate your time and energy reviewing my questions. 感谢您花费时间和精力回顾我的问题。

Thanks to 2017, you have many possible solutions. 多亏了2017,您有了许多可能的解决方案。 One of them should be match to your situation: 其中之一应符合您的情况:

  1. Submit the form via AJAX. 通过AJAX提交表单。 (No reload, no tab to open) (不重新加载,没有选项卡打开)
  2. Maybe you have any change like a message after submitting the form, so you know, that you have to open the "form-tab"? 提交表单后,您可能会像消息一样进行任何更改,所以您知道必须打开“表单选项卡”吗?
  3. Save the current tab in a hidden input field and read this input field on load to see what tab you have to open 将当前选项卡保存在隐藏的输入字段中,并在加载时阅读此输入字段,以查看必须打开的选项卡
  4. Save current tab to url and read URL on load to see what tab you have to open 将当前标签保存到url并读取加载时的URL,以查看必须打开的标签

Forget 3 and 4 and work on solution 1 or 2, please. 请忘记3和4,然后尝试解决方案1或2。

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

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