选择和以编程方式加载jQuery选项卡 [英] selecting & loading a jquery tab programmatically

查看:102
本文介绍了选择和以编程方式加载jQuery选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使此功能正常工作时遇到了麻烦.我想在页面加载时自动加载选项卡.我已经使用了以下代码.

I'm having trouble trying to get this functionality to work. I would like to load a tab automatically when the page loads. I have used the following code.

$tabs.tabs('select', 0); 

但是,发生的是它只是选择它而没有加载它(该选项卡通过ajax加载).有趣的是,当我选择另一个选项卡,然后再次回到第一个选项卡时,它加载正常.

However, what's happening is that it's only selecting it and not loading it (that tab loads via ajax). Interestingly when I select another tab and then go back to the 1st tab again then it loads fine.

推荐答案

您是否尝试在初始化时指定选定的选项卡:

Have you tried specifying the selected tab at the time of initialization:

var $tabs = $('.selector').tabs({ selected: 0 });

初始化后,您可以通过编程方式选择一个标签页:

After initialization, you can do this to programmatically select a tab:

$tabs.tabs('option', 'selected', 0);

这对我来说非常合适:

var $tabs = jQuery("#tabDiv > ul").tabs( { selected: null } );
$tabs.tabs("select", 0);

这篇关于选择和以编程方式加载jQuery选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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