1

I'm working with jquery UI tabs. (jquery 1.11.1,jQuery ui 1.11.1)

I've the following <base> tag in head>:

<base href="http://mytestdomain.com/" />

Now when the page loads jquery UI makes two tabs out of my two <li>'s and then tries to load the content from base url via ajax. jQuery ui doesn't know that the href of anchors are not "external", but "local" hence fails to load the content.

My html:

<div id="container-1">
    <ul>
        <li><a href="#fragment-1">some text1</a></li>
        <li><a href="#fragment-2">some text2</a></li>
    </ul>
    <div id="fragment-1"> 
      LOREM IPSUM1
    </div>
    <div id="fragment-2"> 
      LOREM IPSUM2
    </div>
 </div>

My javascript:

<script type="text/javascript">
    $(document).ready(function() {
        $('#container-1').tabs();
    });    
</script>

Can someone help me please?

T J
  • 42,762
  • 13
  • 83
  • 138
brandelizer
  • 342
  • 3
  • 17

1 Answers1

2

Because of your base tag: <base href="http://mytestdomain.com/" />

The links having segments will be interpreted like the following:

<a href="http://mytestdomain.com/#fragment-2">some text2</a>

That certainly won't work since it's pointing to a directory.

Modifying the href of the hyperlinks to include the remaining path till the file containing the segment will fix the issue.

For example:

<a href="index.html#fragment-2">some text2</a>

will be interpreted as

<a href="http://mytestdomain.com/index.html#fragment-2">some text2</a>

and jQuery-UI will find the element having id fragment-2 from index.html

T J
  • 42,762
  • 13
  • 83
  • 138
  • You are right, but look at my answer below. editing the anchot (http://mytestdomain.com/index.html#fragment2) does not work, but i do not know why.... – brandelizer Nov 21 '14 at 14:40
  • 1
    @brandelizer don't add `mytestdomain.com/index.html#fragment2` while having a base url, either just add `index.html#fragment2` so that the base url will be prepended to it, or use `http://mytestdomain.com/index.html#fragment2` so that the base will be skipped. I tested the first method locally and it works... – T J Nov 21 '14 at 15:04
  • OK.I had more than one tab module in the page and i have tried it only on the first. Thank you verry much for your work! I hope I can return the favor – brandelizer Nov 24 '14 at 07:40