Search code examples
javascriptjqueryjquery-uitabs

Error in jQuery UI Tabs: Mismatching fragment identifier


Here's my code:

<div id="tablesTabs">
        <ul>
            <li><a id="changed" href="#changedTable"><% "Changed" %></a></li>
            <li><a id="unchanged" href="#changedTable"><% "Unchanged"%></a></li>
        </ul>
    </div>

<div id="tablesDiv">
        <div id="changedTable" style="width:100%; height:430px;"></div>
    </div>

And in a javascript:

$(function () {
        $("#tablesTabs").tabs({
            cache: true
        }).scrollabletab();
        loadTables();
    });

if ($('#tablesTabs').tabs("option", "selected") == 0) {
    //fill table with data
}

if ($('#tablesTabs').tabs("option", "selected") == 1) {
    //fill table with other data
}

The first tab seems fine, the grid is alright. But when I click on the second tab I get error Uncaught jQuery UI Tabs: Mismatching fragment identifier. What is the problem and how to fix it?


Solution

  • First, I would see if the problem is that your two tabs have identical link in their href-attribute. Both have #changedTable, try having unique href for each tab.

    Secondly, your tab setup looks unfamiliar to me. Maybe it's fine but I always have the content divs inside the tab div.

    As:

    <div id="tabs">
      <ul>
        <li><a href="#tab-1">Something</a></li>
        <li><a href="#tab-2">Something else</a></li>
      </ul>
    
      <div id="tab-1">
        <p>Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla.</p>
      </div>
      <div id="tab-2">
        <p>Curabitur ornare consequat nunc. Aenean vel metus.</p>
      </div>
    </div>