在 jQuery 模态窗口中保存选项卡以供将来显示
长期读者,第一次海报。
我遇到了一个你们很多人都会觉得微不足道的问题,但我花了很长时间来解决这个问题,而且我似乎无法在互联网上找到任何线索。
作为 JavaScript 的全面清理,我尝试使用 JQuery.ui smartmodal 窗口(v 1.8.rc1)在两个单独的选项卡中显示两支足球队。就像 Tab(0) 中的法国和 Tab(1) 中的英国一样。
当我打开此模式窗口时,默认情况下始终打开第一个选项卡(法国)。
直到这里一切都很好:我正在尝试通过记住用户关闭模式时所查看的最后一个选项卡是什么来改进此模式窗口,以便在用户重新打开时重新打开它(默认情况下,尽管第一个选项卡)这个模式在后面。
我已经尝试过使用“选择和选择”功能。以编程方式加载 jquery 选项卡 » 方法,但没有任何成功,而且我正在慢慢耗尽选项(和时间)。
感谢您阅读我的文章,如果您对如何在 smartmodal 调用中使用参数有任何想法,那将对我有很大帮助。
long time reader, first time poster.
I’m coming with an issue that many of you will find trivial but I’m bashing my head against it for too long time and I can’t seems to find any clue on the internet.
As a total scrubs with JavaScript, I’m trying to use JQuery.ui smartmodal windows (v 1.8.rc1) for displaying two football teams in two separate tabs. Like France in Tab(0) and England in Tab(1).
When I open this modal window, the first tab (France) is always opened by default.
Everything’s fine until here : I’m trying to improve this modal window by remembering what was the last Tab the user was looking when he closed the modal, for reopening it (in spite of the first tab, by default) when the user will reopen this modal latter on.
I’ve already tried to use the “selecting & loading a jquery tab programatically » method but without any kind of success, and I’m slowly running out of options (and time).
Thanks for reading me, if you have any idea on how can I use a parameter in the smartmodal call, that would greatly help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 .tabs("select", index) 方法选择“打开”哪个选项卡。
例如:
将选择第二个选项卡。
此时,只需将先前选择的选项卡的索引存储在可访问的位置即可(该信息的最佳位置取决于您和您的特定问题)。您可以触发此存储,为 select 事件附加一个事件处理程序,每次用户更改显示的选项卡时都会调用该事件处理程序。
如果您在使用此方法时遇到问题,请确保在正确的位置触发选择命令(即在选项卡正确初始化之后),并确保将最后选择的选项卡存储在不会消失的良好位置当模式关闭时。
You can select which tab is "opened" by using the .tabs("select", index) method.
For instance:
would select the second tab.
At that point it is simply a matter of storing the index of the previously selected tab somewhere accessible (the best location for that information is up to you and your particular problem). You can trigger this storage attaching an event handler for the select event, which will get called every time a user changes the tab being shown.
If you are having trouble with this method make sure you are triggering the select command in the proper location (i.e. after the tabs have been correctly initialized) and make sure you are storing the last selected tab in a good location that doesn't go away when the modal closes.
如果我理解正确的话,你的选项卡在这个模式中吗?您可以做的是设置一个 cookie,其中包含与最后选择的选项卡相对应的值。然后,您的服务器端代码可以设置包含该值的 JavaScript 变量。调用对话框/选项卡时,您可以使用此值再次设置选定的选项卡。
If I understand correctly your tabs are inside this modal? What you could do is set a cookie, containing a value that corresponds with the last selected tab. You server side code can then set a javascript variable containing this value. When calling the dialog/tab you can use this value to set the selected tab again.