Skip to content

Commit

Permalink
Do not prevent default if the element that triggers is a checkbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmariuzzo committed May 15, 2014
1 parent 896d609 commit f2f4df1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build/jquery.checkboxes.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/jquery.checkboxes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*! Checkbox.js - MIT - Rubens Mariuzzo */ ! function($) {
/*! Checkbox.js - MIT - Rubens Mariuzzo */

! function($) {

//////////////////////////////////
/* Checkboxes class definition. */
Expand Down Expand Up @@ -128,7 +130,9 @@
$context = $(el.data('context') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))),
action = el.data('action');
if ($context && action) {
e.preventDefault();
if (!el.is(':checkbox')) {
e.preventDefault();
}
$context.checkboxes(action);
}
});
Expand Down
7 changes: 7 additions & 0 deletions test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@
<a href="#checkboxes"
data-toggle="checkboxes"
data-action="uncheck">Uncheck all</a>
<label>
<input type="checkbox"
data-context="#checkboxes"
data-toggle="checkboxes"
data-action="toggle">
Check all
</label>
</body>
</html>

0 comments on commit f2f4df1

Please sign in to comment.