All basic question types
This commit is contained in:
parent
3e1e5618ca
commit
4fe218166f
51 changed files with 760 additions and 92 deletions
23
app/javascript/simple_input.js
Normal file
23
app/javascript/simple_input.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import debounce from 'debounce'
|
||||
|
||||
const csrfToken = document.querySelector("[name='csrf-token']").content
|
||||
|
||||
export default function initSimpleQuestions() {
|
||||
document.querySelectorAll('[data-behaviour="question_simple_input"]').forEach((input) => {
|
||||
const submitUrl = input.dataset.submitUrl
|
||||
|
||||
const handleInput = debounce(() => {
|
||||
fetch(submitUrl, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"x-csrf-token": csrfToken,
|
||||
"content-type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ value: input.value }),
|
||||
})
|
||||
}, 300)
|
||||
|
||||
input.addEventListener('change', handleInput)
|
||||
input.addEventListener('input', handleInput)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue