具有基础href和查询字符串的jQuery ui选项卡不起作用 [英] jQuery ui tabs with base href and query string doesn't work

查看:109
本文介绍了具有基础href和查询字符串的jQuery ui选项卡不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery ui标签正在为我工​​作,但是当我在它后面放置一个查询字符串时,它将加载到基础href内容中。



也许我不是了解基准href /相关链接的正确行为。但是这里是我的设置:

Base href: http://example.com/
相关链接:random / link / example.do。
Hastag像这样:#fragment-1。

Full link: http://example.com/random/link/example#fragment-1



这就是我的链接的样子。当我把查询字符串放在它后面时,它不起作用。像这样:
http://example.com/random/link/example?刷新= 2



我找到了一些调整源代码的修复程序。 (链接)。但有没有办法解决这个问题,而无需调整源代码?



谢谢 你可以试试这个

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

$(#tabs)。 tabs();
});

以下是小提琴以显示它的工作。


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.

Maybe i'm not understanding the correct behaviour of base href/relative links. But here is my set up:
Base href: http://example.com/ .
Relative link: random/link/example.do.
Hastag like so: #fragment-1 .
Full link: 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

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.

这篇关于具有基础href和查询字符串的jQuery ui选项卡不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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