Skip to content

Commit f2f4df1

Browse files
committed
Do not prevent default if the element that triggers is a checkbox.
1 parent 896d609 commit f2f4df1

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

build/jquery.checkboxes.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.checkboxes.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/*! Checkbox.js - MIT - Rubens Mariuzzo */ ! function($) {
1+
/*! Checkbox.js - MIT - Rubens Mariuzzo */
2+
3+
! function($) {
24

35
//////////////////////////////////
46
/* Checkboxes class definition. */
@@ -128,7 +130,9 @@
128130
$context = $(el.data('context') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))),
129131
action = el.data('action');
130132
if ($context && action) {
131-
e.preventDefault();
133+
if (!el.is(':checkbox')) {
134+
e.preventDefault();
135+
}
132136
$context.checkboxes(action);
133137
}
134138
});

test/test.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@
4747
<a href="#checkboxes"
4848
data-toggle="checkboxes"
4949
data-action="uncheck">Uncheck all</a>
50+
<label>
51+
<input type="checkbox"
52+
data-context="#checkboxes"
53+
data-toggle="checkboxes"
54+
data-action="toggle">
55+
Check all
56+
</label>
5057
</body>
5158
</html>

0 commit comments

Comments
 (0)