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.
 
 
 
 
 

19 lines
522 B

Turbo.config.forms.confirm = (title) => {
const dialog = document.getElementById("main-dialog")
const dialogTitle = dialog.querySelector('[data-modal=title]')
const previousTitleContent = dialogTitle.textContent
dialogTitle.textContent = title
dialog.showModal()
return new Promise((resolve, _) => {
dialog.addEventListener(
"close",
() => {
dialogTitle.textContent = previousTitleContent
resolve(dialog.returnValue == "confirm")
},
{ once: true },
);
});
}