You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/javascript/elements/set_value.js

12 lines
391 B

export default class extends HTMLElement {
connectedCallback () {
const input = this.dataset.inputId ? document.getElementById(this.dataset.inputId) : this.querySelector('input')
this.firstElementChild.addEventListener(this.dataset.on || 'click', () => {
if (this.dataset.emptyOnly !== 'true' || !input.value) {
input.value = this.dataset.value
}
})
}
}