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.
32 lines
948 B
32 lines
948 B
Turbo.config.forms.confirm = (title) => {
|
|
console.log('confirm called')
|
|
const dialog = document.getElementById("front-dialog")
|
|
dialog.showModal()
|
|
return new Promise((resolve) => {
|
|
dialog.addEventListener("close", () => { resolve(dialog.returnValue == "confirm") }, { once: true })
|
|
})
|
|
}
|
|
|
|
Turbo.config.forms.showModal = (dialogId) => {
|
|
console.log('showModal called', dialogId)
|
|
}
|
|
document.addEventListener('turbo:submit-start', (e) => {
|
|
const dialogId = e.explicitOriginalTarget.dataset.turboShowModal
|
|
if (dialogId) {
|
|
e.detail.formSubmission.stop()
|
|
Turbo.config.forms.showModal(dialogId)
|
|
}
|
|
})
|
|
|
|
Turbo.config.forms.closeModal = (dialogId) => {
|
|
console.log('closeModal called', dialogId)
|
|
}
|
|
document.addEventListener('turbo:submit-start', (e) => {
|
|
const dialogId = e.explicitOriginalTarget.dataset.turboCloseModal
|
|
if (dialogId) {
|
|
e.detail.formSubmission.stop()
|
|
Turbo.config.forms.closeModal(dialogId)
|
|
}
|
|
})
|
|
|
|
|