Last active
February 2, 2016 06:57
-
-
Save pobing/6ce480a0ad5904807798 to your computer and use it in GitHub Desktop.
js checkAll or subCheck
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
attached: -> | |
$subQuestion = @$("input[name='question_ids[]']") | |
checkedLengh = @$("input[name='question_ids[]']:checked").length | |
allChecked = checkedLengh > 0 and $subQuestion.length is checkedLengh | |
@$(".question-check-all").prop("checked", allChecked) | |
checkAll: (e) -> | |
checkboxes = $('input[name="question_ids[]"]') | |
_.each checkboxes, (box) => | |
box.checked = e.currentTarget.checked | |
subChecked: (e) -> | |
allValue = _.map $("input[name='question_ids[]']"), (el) -> el.checked | |
isAllChecked = _.every allValue | |
$(".question-check-all").prop("checked", isAllChecked) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment