Have to click tab twice to see content (lagging)

Have to click tab twice to see content (lagging)


I'm experiencing some problems with jquery's tab component.
I have a couple of tabs, all with content loaded on demand when a tab
is selected. The problem is this. If an ajax call takes some time and
another tab is clicked before the call has finished and the content
has been displayed, the tab component ends up in a strange state.
When in this state the content is lagging after with one click. If a
tab is clicked it is highlighted but the content is not displayed. If
it is clicked again the ajax call is triggered and the content is
fetched.
Has anyone experienced similar problems?
<script type="text/javascript">
$(function(){
$("#tabsDistribution").tabs({
                spinner: 'Retrieving data...',
            cache: false,
            selected: 0,
                load: function(event, ui) {
                    loading.hideLoading();
             }
             });
             $('#tabsDistribution').tabs().bind("tabsselect", function
(event, ui) {
                 loading.showLoading();
                digiplug_clearErrorMessages();
            });
        });
         function setEmptyErrorMessage(){
        document.getElementById("errorMessageArea").style.display =
'none';
     }
    </script>
    <div id="tabsDistribution">
        <ul>
            <authz:authorize
ifAllGranted="ACTION_ACCESS_DISTRIBUTION_OVERVIEW">
                <li>
                    <a href="${overviewURL}">
                        <fmt:message key="operations.distribution.overview" />
                    </a>
                </li>
            </authz:authorize>
            <authz:authorize ifAllGranted="ACTION_ACCESS_DISTRIBUTION_BATCHES">
                <li>
                    <a id="distributionBatches" href="${distributionBatchesURL}"
onClick="setEmptyErrorMessage()">
                        <fmt:message key="operations.distribution.batches" />
                    </a>
                </li>
            </authz:authorize>
            <authz:authorize
ifAllGranted="ACTION_ACCESS_DISTRIBUTION_SEARCH_CATALOGUE">
                <li>
                    <a href="${distributionBPCatalogsURL}"
onClick="setEmptyErrorMessage()" >
                        <fmt:message key="operations.distribution.bp-catalogs" />
                    </a>
                </li>
            </authz:authorize>
            <authz:authorize
ifAllGranted="ACTION_ACCESS_DISTRIBUTION_SEARCH_SYNC">
                <li>
                    <a href="${distributionDeliveryInstructionsURL}"
onClick="setEmptyErrorMessage()">
                        <fmt:message key="operations.distribution.synch-instructions" />
                    </a>
                </li>
            </authz:authorize>
            <!-- Out of scope for go live
                <li>
                    <a href="#tabDistributionActivityForcast"
onClick="setEmptyErrorMessage()">
                        <fmt:message key="operations.distribution.activity-forecast" />
                    </a>
                </li>
            -->
            <authz:authorize
ifAllGranted="ACTION_ACCESS_DISTRIBUTION_AUDIT_TRAIL">
            <li>
                    <a href="${distributionAuditTrailsURL}"
onClick="setEmptyErrorMessage()">
                        <fmt:message key="operations.distribution.audit-trails" />
                    </a>
            </li>
            </authz:authorize>
        </ul>
        <!--
        <div id="tabDistributionActivityForcast">
        </div>
        -->
    </div>