在jquery ui中跟踪选项卡事件



我目前有tabs()在一个有4个选项卡的页面上工作。

我正在尝试使用事件跟踪来跟踪选项卡的点击,除了初始页面加载外,它运行良好。我想让页面识别页面加载时加载了哪个选项卡,但它没有注册

我的代码:

$( "#tabs" ).tabs({ 
//activate to pass the active tab on click to the hidden field
activate: function( event, ui ) {
$('#activeTab').val($("#tabs").tabs('option', 'active'));
trackEvent('DeptPerformance', 'Tabs', $("#tabs .ui-tabs-active").text());
},
disabled: [<?=($isGroup?0:'')?>],
active: <?=($isGroup?1:0)?>
});

我试着添加:

create: function( event, ui ) {
trackEvent('DeptPerformance', 'Tabs', $("#tabs .ui-tabs-active").text());
},

但这并不能追踪事件。

页面加载后,我是否应该使用其他方法或事件来跟踪事件?

进一步的测试发现,在创建选项卡时没有加载分析代码-添加了一个等待1秒的超时,以便分析赶上。

要修复:

$( "#tabs" ).tabs({ 
//activate to pass the active tab on click to the hidden field
activate: function( event, ui ) {
$('#activeTab').val($("#tabs").tabs('option', 'active'));
trackEvent('DeptPerformance', 'Tabs', $("#tabs .ui-tabs-active").text());
},
create: function( event, ui ) {
setTimeout(function(){
trackEvent('DeptPerformance', 'Tabs', $("#tabs .ui-tabs-active").text());
}, 1000);
},
disabled: [<?=($isGroup?0:'')?>],
active: <?=($isGroup?1:0)?>
});

最新更新