在后台预加载JQuery UI选项卡 [英] Preload JQuery UI tabs in the background

查看:60
本文介绍了在后台预加载JQuery UI选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部

在第一个选项卡仍在加载时,如何预加载所有JQuery UI选项卡?我已经尝试过remote:true选项,但是没有用?标签页加载时,每个标签页名称旁边应有ajax微调框.

How can I preload all JQuery UI tabs while the first tab is still loading? I have tried the remote:true option, but it didnt work? There should be ajax spinners next to each tab name while the tabs are loading.

谢谢

推荐答案

尝试如下操作:

$tabs = $('#tabs').tabs({
    cache: true
});
var total = $tabs.find('.ui-tabs-nav li').length;
var currentLoadingTab = 1;
$tabs.bind('tabsload',function(){
    currentLoadingTab++;
    if (currentLoadingTab < total)
        $tabs.tabs('load',currentLoadingTab);
    else
        $tabs.unbind('tabsload');
}).tabs('load',currentLoadingTab);

它使用cache选项初始化选项卡,以便在一次加载后不会重新加载选项卡. 然后,它找出选项卡的总数,并将要加载的下一个选项卡设置为1(以0开头的选项卡进行索引) 然后,它将一个事件绑定到加载事件上,以开始加载下一个选项卡,直到将所有选项卡都击中.要启动它,然后加载第二个选项卡.

It initializes the tabs with the cache option so that tabs aren't reloaded after they have been loaded once. It then finds out the total number of tabs and sets the next tab to load as 1 (tabs are indexed starting with 0 ) Then it binds an event on the load event to start loading the next tab until it has hit all of them. To start it of it then loads the second tab.

这篇关于在后台预加载JQuery UI选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆