Twitter Bootstrap-在“显示"标签上执行操作事件 [英] Twitter Bootstrap - Perform action on tab "shown" event

查看:88
本文介绍了Twitter Bootstrap-在“显示"标签上执行操作事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要基于引导jQuery选项卡部分中的所选选项卡重置"一些页面信息.

I need to "reset" some page information based on the selected tab in a bootstrap jQuery tab section.

文档显示了此事件,这正是我所需要的: http://twitter .github.com/bootstrap/javascript.html#tabs

The docs show this event, which is exactly what I need: http://twitter.github.com/bootstrap/javascript.html#tabs

$('a[data-toggle="tab"]').on('shown', function (e) {
  e.target // activated tab
  e.relatedTarget // previous tab
})

我需要获取e.Targete.relatedTarget的'href'属性,它们唯一地标识这两个选项卡以及它们链接到的2个选项卡内容窗格.

I need to get the 'href' attribute of the e.Target and e.relatedTarget, which uniquely identify those 2 tabs and the 2 tab-content panes they are linked to.

这是我的问题:e对象是我不期望或不习惯使用的对象.我不能使用像e.target.attr('href')这样的jQuery方法-我曾经使用的所有普通jquery方法都已消失.我尝试像原始对象属性那样访问它-e.href,得到了https://127.0.0.1/test?action=view#tab-a"而不是#tab-a

Here's my problem: the e object is some object that I'm not expecting or used to. I can't use any of the jQuery methods like e.target.attr('href') -- all the normal jquery methods I'm used to are gone. I tried accessing it like a raw object attribute -- e.href , and got https://127.0.0.1/test?action=view#tab-a" not #tab-a

我可以为此编写变通方法-但我显然做错了什么.应该有一种简单的方法可以直接从e.target获取#tab-a,但是我无法弄清楚.

I can code a workaround with this - but I'm clearly doing something wrong. There should be an easy way to directly get #tab-a from e.target -- but I can't figure it out.

推荐答案

改为尝试$(e.target).attr('href').

这篇关于Twitter Bootstrap-在“显示"标签上执行操作事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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