Skip to content

Instantly share code, notes, and snippets.

@pobing
Last active February 2, 2016 06:57
Show Gist options
  • Save pobing/6ce480a0ad5904807798 to your computer and use it in GitHub Desktop.
Save pobing/6ce480a0ad5904807798 to your computer and use it in GitHub Desktop.
js checkAll or subCheck
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