Skip to content

Commit

Permalink
Fix checkbox selector, closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Frantisek Vesely committed Mar 10, 2017
1 parent b84482d commit 75b72f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/coffee/happy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Happy
thicknessify: (input, happy_input) ->
if input.classList.contains('thin')
happy_input.classList.add('thin')


setNames: (input, happy_input) ->
happy_input.setAttribute('data-name', input.getAttribute('name'))
Expand Down Expand Up @@ -135,6 +135,9 @@ class Happy
e.preventDefault()

selector = 'input[type=checkbox][name="'+happy_input.getAttribute('data-name')+'"]'
value = happy_input.getAttribute('data-value')
if typeof(value != 'undefined') and value != false and value != null
selector += '[value="' + value + '"]'
input = document.querySelector(selector)

if input
Expand Down Expand Up @@ -162,6 +165,9 @@ class Happy

checkCheckboxState: (input) =>
selector = '.happy-checkbox[data-name="'+input.getAttribute('name')+'"]'
value = input.getAttribute('value')
if typeof(value != 'undefined') and value != false and value != null
selector += '[data-value="' + value + '"]'
element = document.querySelector(selector)

if element
Expand Down

0 comments on commit 75b72f1

Please sign in to comment.