如何禁用 jQuery UI 选项卡中的哈希更改

发布于 2024-12-29 17:17:16 字数 279 浏览 3 评论 0原文

我想使用 jquery ui tabs 插件,但当我单击选项卡时不让它更改 url 哈希。

我正在使用一个单独的插件来管理历史记录,但它却搞砸了。

换句话说,当我单击选项卡时,内容应该改变,但 url 哈希值不会改变

有什么想法吗?

文档位于此处,但没有提及任何相关内容。

编辑:这很奇怪,我不确定是什么导致它改变了窗口哈希。但它不再发生了。

I'd like to use jquery ui tabs plugin, but not have it changing the url hash when I click a tab.

I'm using a separate plugin for managing history, and it's screwing with it.

In other words, when I click a tab the content should change, but not the url hash

Any ideas?

The Docs are here, but it doesn't mention anything about this.

Edit : Thats weird, I'm not sure what was causing it to change the window hash. It's not occurring anymore though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梅倚清风 2025-01-05 17:17:16

遇到同样的问题。干得好!

// Prevent hashtag change on tab link click
$('.ui-tabs-nav a').live('click', function(e){
    e.preventDefault();
    e.stopPropagation();
});

Having the same problem. Here you go!

// Prevent hashtag change on tab link click
$('.ui-tabs-nav a').live('click', function(e){
    e.preventDefault();
    e.stopPropagation();
});
橙幽之幻 2025-01-05 17:17:16

http://jqueryui.com/demos/tabs/default.html

url 哈希不不为我改变。您使用什么插件来管理历史记录?

http://jqueryui.com/demos/tabs/default.html

The url hash doesn't change for me. What plugin are you using for managing history?

哑剧 2025-01-05 17:17:16

你可以尝试一下吗:

var currentHash = top.location.hash;

$('#example').bind('tabsshow', function(event, ui) {
   top.location.hash = currentHash;
}

我没有尝试过,我这里无法设置环境。当您重置哈希值时,它的行为可能不会如您所愿......

can you please try:

var currentHash = top.location.hash;

$('#example').bind('tabsshow', function(event, ui) {
   top.location.hash = currentHash;
}

i haven't tried it, i can't set up the environment here. It is possible that when you reset the hash, it doesn't behave as you wish...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文