简体   繁体   English

jquery-ui 1.10.4中的Capture选项卡选择事件

[英]Capture tab select event in jquery-ui 1.10.4

I'm trying to capture a tab selection event, something exactly like the this jsfiddle from this similar question from almost 3 years ago. 我正在尝试捕获一个选项卡选择事件,就像来自将近3年前的类似问题中的 jsfiddle一样。 The following code works when using jquery-ui-1.8.9 as in the linked jsfiddle: 当在链接的jsfiddle中使用jquery-ui-1.8.9时,以下代码可以工作:

<script>
$('#tabs').tabs({
      select: function(event, ui){
             //do stuff
      }
});
 </script>
 <div id="tabs">
        <ul>
            <li><a href="#tabs-1">First</a></li>
            <li><a href="#tabs-2">Second</a></li>
            <li><a href="#tabs-3">Third</a></li>
        </ul>
        <div id="tabs-1">
            <iframe src="page1.html" width="100%" height="600" marginheight="0" frameborder="0"></iframe>
        </div>
        <div id="tabs-2">
            <iframe src="page2.html" width="100%" height="600" marginheight="0" frameborder="0"></iframe>
        </div>
        <div id="tabs-3">
            <iframe src="page3.html" width="100%" height="600" marginheight="0" frameborder="0"></iframe>
        </div>
    </div>

I can't seem to find any method that works in the newer version. 我似乎找不到在较新版本中可用的任何方法。 I'd very much like to avoid going backwards to 1.8.9 here, but it's necessary for me to be able to detect when a tab is selected. 我非常想避免在这里退回到1.8.9,但是对我来说,必须能够检测到何时选择了选项卡。 Has anyone else run into this issue? 还有其他人遇到这个问题吗? I'm sure it's something straightforward but I can't figure it out. 我敢肯定这很简单,但我无法弄清楚。

In jQuery UI 1.10.* it's activate rather than select: 在jQuery UI 1.10。*中,它是激活的而不是选择:

$('#tabs').tabs({
    activate: function(event, ui){
        //do stuff
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM