JQuery UI Tabs caching

前端 未结 4 1277
不思量自难忘°
不思量自难忘° 2020-12-09 06:18

I am working in an ASP .net MVC Application. I have a JQuery UI tab whose Javascript to enable caching is as follows.

function LoadStudentDetailTabs() {
            


        
4条回答
  •  悲哀的现实
    2020-12-09 06:54

    So, simplifying Eric's analysis, you can control the caching of each tab by setting the 'cache.tabs' data in each tab's anchor element.

    // disable cache by default
    $("#tabs").tabs({
        cache: false,
    });
    

    Then after the tab content has been loaded for the first time, you can enable the caching for that tab. I would simply put it in the $(document).ready:

    $(document).ready(function () {
        // cache content for the current tab
        var currentTabIndex = $("#tabs").tabs('option', 'selected');
        var currentTabAnchor = $("#tabs").data('tabs').anchors[currentTabIndex];
        $(currentTabAnchor).data('cache.tabs', true)
    });
    

    Thanks, Eric!

提交回复
热议问题