jQuery Mobile tabs disable(): Uncaught Error: jQuery UI Tabs: Mismatching fragment identifier

277 Views Asked by At

I am getting an error after using disable() on tabs. After having used disable() whenever I hit one of the tabs I get:

Uncaught Error: jQuery UI Tabs: Mismatching fragment identifier.

on the log (in Chromium). There is no apparent malfunction, though; tab swiching works as expected.

I wonder if I am doing something wrong or this is a bug in jQuery Mobile.

See sample:

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
    href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script
    src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

<script>
$(document).ready(function() {
    var disabledTabs = [ 1 ];
    $('#navbar').tabs({disabled: disabledTabs});
});
</script>

</head>
<body>
    <div data-role="tabs" id="tabs">
        <div id="navbar" data-role="navbar">
            <ul>
                <li><a href="#one" data-ajax="false">one</a></li>
                <li><a href="#two" data-ajax="false">two</a></li>
                <li><a href="#three" data-ajax="false">three</a></li>
            </ul>
        </div>
        <div id="one" class="ui-body-d ui-content">First</div>
        <div id="two" class="ui-body-d ui-content">Second</div>
        <div id="three" class="ui-body-d ui-content">Third</div>
    </div>

</html>
</body>

Thanks in advance

2

There are 2 best solutions below

0
vijayP On

Your data <div> should be inside main navbar div as follows:

<div id="navbar" data-role="navbar">
    <ul>
        <li><a href="#one" data-ajax="false">one</a></li>
        <li><a href="#two" data-ajax="false">two</a></li>
        <li><a href="#three" data-ajax="false">three</a></li>
    </ul>
    <div id="one" class="ui-body-d ui-content">First</div>
    <div id="two" class="ui-body-d ui-content">Second</div>
    <div id="three" class="ui-body-d ui-content">Third</div>
</div>

Because of this you get such exception. Just correct the HTML and the code should work properly.

1
ezanker On

The problem is that the tabs widget is associated with the DIV id="tabs", not the navbar div.

So instead of

$('#navbar').tabs({disabled: disabledTabs});

change it to

$('#tabs').tabs({disabled: disabledTabs});