Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/tangy-checkboxes-dynamic-bugfix'…
Browse files Browse the repository at this point in the history
… into release/v4.3.3
  • Loading branch information
rjcorwin committed Oct 7, 2019
2 parents 5fdcf58 + 987381d commit 9651306
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions input/tangy-checkboxes-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TangyCheckboxesDynamic extends PolymerElement {
}
if (!excludeOption) {
let option = {
value: item[name],
name: item[name],
innerHTML: item[innerHTML]
}
that.optionsList.push(option)
Expand All @@ -170,18 +170,33 @@ class TangyCheckboxesDynamic extends PolymerElement {
let containerEl = this.shadowRoot.querySelector('.container')
let checkboxesEl = document.createElement('tangy-checkboxes')
for (let option of this.optionsList) {
let checkbox = document.createElement('option')
checkbox.name = option.value
checkbox.innerHTML = option.innerHTML
let optionEl = document.createElement('option')
optionEl.name = option.name
optionEl.value = option.name
optionEl.innerHTML = option.innerHTML
try {
checkboxesEl.appendChild(checkbox)
checkboxesEl.appendChild(optionEl)
} catch (e) {
console.log("e: " + e)
}
}
let newValue = []
checkboxesEl.addEventListener('change', this.onCheckboxesClick.bind(this))
newValue = checkboxesEl.getProps()
if (!this.value || (typeof this.value === 'object' && this.value.length < newValue.length)) {
this.value = newValue
}
containerEl.appendChild(checkboxesEl)
}

onCheckboxesClick(event) {
let newValue = []
let el = this.shadowRoot.querySelector('tangy-checkboxes')
newValue = el.getProps()
this.value = newValue.value
this.dispatchEvent(new CustomEvent('change'))
}


}
window.customElements.define(TangyCheckboxesDynamic.is, TangyCheckboxesDynamic);

0 comments on commit 9651306

Please sign in to comment.