简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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