Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkbox selector, closes #7 #12

Merged
merged 1 commit into from
Mar 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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