"Recipients Selector"
Bootstrap 3.0.3 Snippet by travislaynewilson

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
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<h3>Recipients Selector w/ jQuery Checkbox Buttons<br />
<small>Choose your recipients, and display the results below!</small>
</h3>
<p><code>NOTE: These elements are not hooked together - like many other samples on bootsnipp.com, this is a framework sample.</code></p>
<br />
<div class="panel panel-default recipients">
<div class="panel-heading">
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">All Guests</button>
<input type="checkbox" id="showall" class="hidden" checked />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">Not Yet Invited</button>
<input type="checkbox" id="showall" class="hidden" />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">Yes RSVP</button>
<input type="checkbox" id="showall" class="hidden" />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">No RSVP</button>
<input type="checkbox" id="showall" class="hidden" />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">Maybe RSVP</button>
<input type="checkbox" id="showall" class="hidden" />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">Not Yet Replied</button>
<input type="checkbox" id="showall" class="hidden" />
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
.recipients .panel-body {
overflow: auto;
max-height: 200px;
}
.recipients .recipient {
display: block;
float: left;
width: 140px;
margin: 0 5px 5px 0;
font-size: 0.85em;
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
}
.recipients .recipient img {
float: left;
height: 28px;
margin-right: 5px;
}
.recipients .recipient .email {
font-size: 0.9em;
color: #999;
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
$(function () {
$('.button-checkbox').each(function () {
// Settings
var $widget = $(this),
$button = $widget.find('button'),
$checkbox = $widget.find('input:checkbox'),
color = $button.data('color'),
settings = {
on: {
icon: 'glyphicon glyphicon-check'
},
off: {
icon: 'glyphicon glyphicon-unchecked'
}
};
// Event Handlers
$button.on('click', function () {
$checkbox.prop('checked', !$checkbox.is(':checked'));
$checkbox.triggerHandler('change');
updateDisplay();
});
$checkbox.on('change', function () {
updateDisplay();
});
// Actions
function updateDisplay() {
var isChecked = $checkbox.is(':checked');
// Set the button's state
$button.data('state', (isChecked) ? "on" : "off");
// Set the button's icon
$button.find('.state-icon')
.removeClass()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments:

The HTML-code is invalid. You are not allowed to use an ID more than 1 time. Why anyway use so many ids? You can do nearly all with classes.

Luzifer () - 9 years ago - Reply 0


We have some similar features for choosing users to be assigned to a development ticket but not this cool.

peaceofcode.com () - 11 years ago - Reply 0


this seems broken

sd () - 11 years ago - Reply 0


How so?

Travis Layne () - 11 years ago - Reply 0


I agree with sd. When I click on the checkboxes nothing happens with the recipients. It just seems like recipients are supposed to change in some way. And I can't select more or less recipients.

Ryan Masterson () - 11 years ago - Reply 0


It's html.. It's up to you to figure out what should happen :)

Looks great btw!

Freddy () - 10 years ago - Reply 0


I can add this functionality, but it seemed to be outside the scope of a Bootstrap snippet. I'll look into adding this.

Travis Layne () - 11 years ago - Reply 0