Created
March 25, 2015 22:40
-
-
Save Lotuashvili/0fc6d53068503fce34c0 to your computer and use it in GitHub Desktop.
Chech/Uncheck all checkboxes with coffeescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.list .checkAll').change -> | |
status = this.checked | |
boxes = $('.list input[type="checkbox"]:not(.checkAll)') | |
boxes.each (i, elem) => | |
elem.checked = status | |
return | |
$('.list input[type="checkbox"]:not(.checkAll)').change -> | |
num = $('.list input[type="checkbox"]:not(.checkAll)').filter(':not(:checked)').length # shows not checked num | |
if num == 0 | |
$('.list .checkAll')[0].checked = true | |
else if num > 0 | |
$('.list .checkAll')[0].checked = false | |
num2 = $('.list input[type="checkbox"]:not(.checkAll)').filter(':checked').length # shows checked num | |
if num2 == 0 | |
deleteAllDisable() # To disable "delete all" button | |
else if num2 > 0 | |
deleteAllEnable() # To enable "delete all" button |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment