JQuery UI选项卡,更改选项卡URL(JQuery 1.10+) [英] JQuery UI Tabs, Change tab URL (JQuery 1.10+)

查看:120
本文介绍了JQuery UI选项卡,更改选项卡URL(JQuery 1.10+)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过jquery/javascript修改jquery ui中选项卡的链接?

Is there a way to modify the link to a tab in jquery ui through jquery/javascript?

样本问题就像

选项卡的URL为"http://thanksforyourhelp/greatly/appreciated/"

如果在该选项卡上提交了表单,则数据将被写入数据库.响应给出添加到数据库中的行的ID.

If a form is submitted on that tab, data is written to the database. The response gives an ID of the row added to the database.

下次访问特定标签时,链接应该实际上是

Next time that specific tab is visited the link should actually be

'http://thanksforyourhelp/greatly/appreciated/ID' 

现在知道该ID,因为来自表单(此处也为ajax)的响应将其发送回了.收到此响应后,我必须重新加载带有ID的URL的当前标签.

where the ID is now known since the response from the form (ajax here as well) sent it back. When this response came I've to reload the current tab with the URL having ID in it.

JQuery 1.10之前的版本.我们可以做这样的事情

Prior to JQuery 1.10. We can do something like this

$("#tabs").tabs("url", index, url);

我们如何在JQuery UI 1.10+中做到这一点.是否在JQuery 1.10中删除了URL方法?

how we can do this in JQuery UI 1.10+. As URL method is removed in JQuery 1.10?

推荐答案

以完整的表单提交方式执行类似的操作.这将更改当前活动选项卡的URL并重新加载该选项卡.

Do something like this in the complete of form submit. This will change the URL of currently active tab and reloads the tab.

var tabs = $("#tabs");
var currentTabIndex = tabs.tabs("option", "active");
var tab = $(tabs.data('uiTabs').tabs[currentTabIndex]);
tab.find('.ui-tabs-anchor').attr('href', "http://thanksforyourhelp/greatly/appreciated/ID");
// If cached initially. Remove cache then
tab.data( "loaded", false);
tabs.tabs("load", currentTabIndex);

这篇关于JQuery UI选项卡,更改选项卡URL(JQuery 1.10+)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆