Finish remaining question types
This commit is contained in:
parent
0d54f756d8
commit
5bd1e821f7
20 changed files with 431 additions and 8 deletions
19
app/javascript/connections_answer.js
Normal file
19
app/javascript/connections_answer.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { Sortable } from 'sortablejs'
|
||||
|
||||
import { submitValue } from './submit_value.js'
|
||||
|
||||
export default function initConnectionsQuestions() {
|
||||
|
||||
|
||||
document.querySelectorAll('[data-behaviour="connections_answer').forEach((list) => {
|
||||
const submitUrl = list.dataset.submitUrl
|
||||
|
||||
Sortable.create(list, {
|
||||
swap: true,
|
||||
onUpdate: (event) => {
|
||||
const newOrder = Array.from(event.to.children).map((el) => Number.parseInt(el.dataset.id))
|
||||
submitValue(submitUrl, { order: newOrder })
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue