blob: 84a026d8ae788fbcdac96d265e667ba023440976 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
@selectTable = ->
$('.table').each ->
selection = []
$(this).on 'click', "[type='checkbox']", (e)->
if e.currentTarget.id == '0'
selection = []
if e.currentTarget.checked
$(this).closest('.table').find("[type='checkbox']").each ->
$(this).prop('checked', true)
# Add each element to selection
selection.push($(this).attr('id'))
# Remove th checkbox from selection
selection.splice(0, 1)
else
$(this).closest('.table').find("[type='checkbox']").each ->
$(this).prop('checked', false)
# Empty selection
selection = []
else
if e.currentTarget.checked
selection.push(e.currentTarget.id)
else
elm = selection.indexOf(e.currentTarget.id)
selection.splice(elm, 1)
# We log the selection (for now)
console.log selection
$(document).on 'ready page:load', selectTable
|