Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui Jquery UI选项卡:帮助开始使用事件_Jquery Ui - Fatal编程技术网

Jquery ui Jquery UI选项卡:帮助开始使用事件

Jquery ui Jquery UI选项卡:帮助开始使用事件,jquery-ui,Jquery Ui,我已经阅读了jQueryUITabs 1.7的文档,我相信我对jQueryTabs的理解有点过头了,因为在单击特定选项卡时会发生特定事件 我有基本的选项卡工作,我只想在选择特定选项卡时将焦点设置在文本框上 UI文档说明您通过以下方式处理选择事件: $('.selector').tabs({ select: function(event, ui) { ... } }); 我不太清楚上面的意思。特别是在stackoverflow,我已经阅读了其他几个例子。不幸的是,演示在提供的答案中不再有效

我已经阅读了jQueryUITabs 1.7的文档,我相信我对jQueryTabs的理解有点过头了,因为在单击特定选项卡时会发生特定事件

我有基本的选项卡工作,我只想在选择特定选项卡时将焦点设置在文本框上

UI文档说明您通过以下方式处理选择事件:

$('.selector').tabs({
   select: function(event, ui) { ... }
});
我不太清楚上面的意思。特别是在stackoverflow,我已经阅读了其他几个例子。不幸的是,演示在提供的答案中不再有效

我当前使用PHP创建和选择特定选项卡的代码是:

$("#tabs").tabs();
$("#tabs").tabs('option', 'selected', <?php echo $tabID-1; ?>);

您要做的是为$'.selector'.tabs函数提供一个JavaScript中的关联数组,该数组称为object。重要的是,JavaScript正在使用这样一个事实,即您可以非常广泛地将函数分配给变量。如果您更容易阅读和理解,可以尝试以下方法:

var tab_select_function = function(event, ui)
{
    // Objects available in the function context:
    // ui.tab     // anchor element of the selected (clicked) tab
    // ui.panel   // element, that contains the selected/clicked tab contents
    // ui.index   // zero-based index of the selected (clicked) tab
    alert("Tab with index " + ui.index + " clicked!");
};

$('#tabs').tabs({
   select: tab_select_function
});

达夫,我实施了你的建议,我正朝着正确的方向前进。在tab_select_函数中,我添加了一些代码来获取选择了哪个选项卡,现在只需提醒它。我遇到的问题是,它正在提醒我来自的选项卡索引,而不是我刚才单击的实际选项卡!var tab_select_function=functionevent,ui{var$tabs=$'tabs'。tabs;var selected=$tabs.tabs'option','selected';alertselected;};我从文档中复制了一些描述,ui对象实际上应该提供您所需的参数。仅供参考:以防其他人偶然发现:您不能通过使用ui选项卡的内置选择事件将焦点设置为输入框。在启用/显示选项卡之前,将触发select事件。您需要使用show:event,而不是使用select事件。
var tab_select_function = function(event, ui)
{
    // Objects available in the function context:
    // ui.tab     // anchor element of the selected (clicked) tab
    // ui.panel   // element, that contains the selected/clicked tab contents
    // ui.index   // zero-based index of the selected (clicked) tab
    alert("Tab with index " + ui.index + " clicked!");
};

$('#tabs').tabs({
   select: tab_select_function
});