开发者

jQuery UI tabs with AJAX - force reloading of tab content every time tab is switched

开发者 https://www.devze.com 2023-01-26 11:21 出处:网络
When using jQuery UI tabs one can specify a .php or .html file as the tab content. Is it possible to force the content inside the ajax tab to refresh when a user goes to another tab and comes back to

When using jQuery UI tabs one can specify a .php or .html file as the tab content. Is it possible to force the content inside the ajax tab to refresh when a user goes to another tab and comes back to it again? (开发者_Go百科The tab contains dynamic information, and the user may perform an action in another tab that necessitates a refresh).


You can use the cache option:

$( ".selector" ).tabs({ cache: true });

More info here: http://jqueryui.com/demos/tabs/#option-cache


I think it does that by default. At least this code shows the values for a split second before it reloads from the ajax call. If not, maybe you can do a reload with this event since it is fired every time a page is navigated to:

$('#tabContainer').bind('tabsselect', function (event, ui) {
    $(ui.panel).html("tab is " + ui.tab + "<br/>\r\n" + // string
        "panel is " + ui.panel + "<br/>\r\n" + // HTMLDivElement
        "index is " + ui.index + "<br/>\r\n" + 
        "Hello, world!");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消