-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0590_nav_tabs_menu_hook_hidden_field_set.html
37 lines (36 loc) · 1.46 KB
/
0590_nav_tabs_menu_hook_hidden_field_set.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!-- タブが変更されたときの検知方法 -->
<!-- changeフックから前(relatedTarget)と後(target)が取得できる -->
<!DOCTYPE html>
<html lang="ja">
<html>
<head>
<meta charset="UTF-8" />
<link href="assets/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
<script src="assets/jquery.js" type="text/javascript"></script>
<script src="assets/coffee-script.js" type="text/javascript"></script>
<script src="assets/bootstrap.js" type="text/javascript"></script>
<script type="text/coffeescript">
$ ->
$("a[data-toggle=tab]").on "shown", (e) ->
# Hiddenタグなどに現在のタブIDを埋め込む例
$("#current_tab").val($(e.target).attr("href").replace("#", ""))
$("a[data-toggle=tab]").bind "show shown", (e) ->
$("#console").prepend("" + e.timeStamp + " " + e.type + " " + $(e.relatedTarget).attr("href") + " → " + $(e.target).attr("href") + "<br/>")
</script>
</head>
<body>
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a href="#t1" data-toggle="tab">(t1)</a></li>
<li><a href="#t2" data-toggle="tab">(t2)</a></li>
</ul>
<div class="tab-content">
<input type="text" id="current_tab" />
<div class="tab-pane active" id="t1">c1</div>
<div class="tab-pane" id="t2">c2</div>
</div>
<hr/>
<div id="console" class="well"></div>
</div>
</body>
</html>