-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bootstrap_Dropdown-Button.htm
140 lines (112 loc) · 5.29 KB
/
Bootstrap_Dropdown-Button.htm
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<!-- saved from url=(0033)http://jsfiddle.net/EtEPJ/6/show/ -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Shopping Cart example with Knockoutjs - jsFiddle demo</title>
<script type="text/javascript" src="./js/jquery-1.7.1.js"></script>
<link rel="stylesheet" type="text/css" href="./css/normalize.css">
<link rel="stylesheet" type="text/css" href="./css/result-light.css">
<script type="text/javascript" src="./js/bootstrap-modal.js"></script>
<link rel="stylesheet" type="text/css" href="./css/bootstrap.css">
<script type="text/javascript" src="./js/bootstrap-dropdown.js"></script>
<style type="text/css">
/* #Basic Styles
================================================== */
body {
background: #fff;
font: 14px/21px "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #444;
-webkit-font-smoothing: antialiased; /* Fix for webkit rendering */
-webkit-text-size-adjust: 100%;
}
h1, h2, h3 {
color: #181818;
font-family: "Georgia", "Times New Roman", Helvetica, Arial, sans-serif;
font-weight: normal;
}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; }
h1 { font-size: 46px; line-height: 50px; margin-bottom: 14px;}
h2 { font-size: 35px; line-height: 40px; margin-bottom: 10px; }
h3 { font-size: 28px; line-height: 34px; margin-bottom: 8px; }
p { margin: 0 0 20px 0; }
input, label {display: inline;}
table { width: 500px; border: 1px solid black;}
th,td {line-height: 2.3em; padding-left: 1ex;}
th { font-weight: bold;}
li {padding-left: 1ex;}
.container { padding: 1ex;}
.fr{ float: right;}
.msg, .msg2 { font-weight: bold; padding-right: 10em; }
.msg{ color: red;}
.msg2{ color: blue;}
/* #Links
================================================== */
a, a:visited { color: #333; text-decoration: underline; outline: 0; }
a:hover, a:focus { color: #000; }
p a, p a:visited { line-height: inherit; }
</style>
</head>
<body>
<div class="container">
<h3>Bootstrap dropdown-button</h3>
<p>Using a dropdown-button / split-button with form elements inside dropdown</p>
<p>I had a <a href="http://stackoverflow.com/questions/9340147/boostrap-2-0-adding-a-login-form-to-a-submenu-preventing-close-on-focus">similar Problem</a> as asked here on stackoverflow. The difference is that i wanted to prevent the closing of the contextmenu / dropdown-toggle if someone clicks on the checkbox.</p>
<p>You can see the <a href="http://jsfiddle.net/EtEPJ/6/">dropdown button example</a> on jsfiddle.net</p>
<table>
<tbody><tr>
<th>Product</th>
<th>Action</th>
</tr>
<tr>
<td>Bike</td>
<td>
<div class="btn-group">
<a class="btn" href="http://jsfiddle.net/EtEPJ/6/show/#">Buy</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="http://jsfiddle.net/EtEPJ/6/show/#">
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="d">buy 1 item (default)</li>
<li class="d">buy 2 item (default)</li>
<li class="f"><label for="cb">gift wrap</label><input type="checkbox" name="cb" id="cb" checked=""></li>
<li><a href="http://jsfiddle.net/EtEPJ/6/show/#" onclick="addItem(this, 4)">buy 4 items (inlinehandler addItem)</a></li>
</ul>
</div>
</td>
</tr>
<tr>
<td>Car</td>
<td>
<div class="btn-group">
<a class="btn" href="http://jsfiddle.net/EtEPJ/6/show/#">Buy</a>
<a class="btn dropdown-toggle" data-toggle="dropdown" href="http://jsfiddle.net/EtEPJ/6/show/#">
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="d">buy 1 item (default)</li>
<li class="d">buy 2 item (default)</li>
<li class="f"><label for="cb">gift wrap</label><input type="checkbox" name="cb" id="cb" checked=""></li>
<li><a href="http://jsfiddle.net/EtEPJ/6/show/#" onclick="addItem(this, 4)">buy 4 items (inlinehandler addItem)</a></li>
</ul>
</div>
</td>
</tr>
</tbody></table>
<br style="clear: both">
<div id="msg" class="msg"></div>
<div id="msg2" class="msg2"></div>
</div>
<script type="text/javascript">//<![CDATA[
;
var op = { opacity: "toggle"};
$(".dropdown-menu li.d").click(function() {
$("#msg").text("Handler for li.d .click() called.").animate(op,800).animate(op,800);
});
$(".dropdown-menu li.f").on('click', function(e) {
e.stopPropagation()
});
function addItem(sender, qty){
var id = sender.parentNode.parentNode.id;
var msg = "Inline function addItem() called called.";
$("#msg2").text(msg + "(id: " + id + ") addItem: qty: " + qty);
}
//]]>
</script>
</body></html>