简体   繁体   English

带有基本href和查询字符串的jQuery ui选项卡不起作用

[英]jQuery ui tabs with base href and query string doesn't work

The jQuery ui tabs is working for me but when I place a query string behind it, it will load in the base href content. jQuery ui标签对我有用,但是当我在其后面放置一个查询字符串时,它将加载到基本href内容中。

Maybe i'm not understanding the correct behaviour of base href/relative links. 也许我不理解基础href /相对链接的正确行为。 But here is my set up: 但这是我的设置:
Base href: http://example.com/ . 基本href: http//example.com/
Relative link: random/link/example.do. 相对链接:random / link / example.do。
Hastag like so: #fragment-1 . Hastag是这样的:#fragment-1。
Full link: http://example.com/random/link/example#fragment-1 完整链接: http//example.com/random/link/example#fragment-1

That's how my link looks like. 这就是我的链接的样子。 When i put a query string behind it, it will not work. 当我把查询字符串放在它后面时,它将无法工作。 Like so: http://example.com/random/link/example?refresh=2 像这样: http//example.com/random/link/example?refresh = 2

I found some fixes that adjust the source code. 我找到了一些调整源代码的修复程序。 ( link ). 链接 )。 But is there a way to fix this without adjusting the source code? 但有没有办法解决这个问题而不调整源代码?

Thanks 谢谢

Hey it's horrible but you can try this 嘿,这太可怕但你可以试试这个

$(function () {
    var rquery = /\?[^#]*/;
    $("#tabs").find("a").each(function() {
        this.setAttribute("data-orig-href", this.href);
        this.href = this.href.replace( rquery, "" );
    });

    $("#tabs").tabs();
});

Here's a fiddle to show it working. 这是一个显示它工作的小提琴

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

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