Sha256: ee0c0e21862f3cde8a31c574db40c1c2e02d2270313e54bdbc2fb4b7b6081f14

Contents?: true

Size: 507 Bytes

Versions: 16

Compression:

Stored size: 507 Bytes

Contents

import { Turbo } from '@hotwired/turbo-rails'

Turbo.config.forms.confirm = (message) => {
  const dialog = document.getElementById('turbo-confirm')
  dialog.querySelector('p').textContent = message
  dialog.showModal()

  dialog.addEventListener('click', (event) => {
    if (event.target.nodeName === 'DIALOG') {
      dialog.close()
    }
  })

  return new Promise((resolve) => {
    dialog.addEventListener('close', () => {
      resolve(dialog.returnValue === 'confirm')
    }, { once: true })
  })
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
avo-3.16.4 app/javascript/js/custom-confirm.js
avo-3.16.3 app/javascript/js/custom-confirm.js
avo-3.16.2 app/javascript/js/custom-confirm.js
avo-3.16.1 app/javascript/js/custom-confirm.js
avo-3.16.0 app/javascript/js/custom-confirm.js
avo-3.15.7 app/javascript/js/custom-confirm.js
avo-3.15.6 app/javascript/js/custom-confirm.js
avo-3.15.5 app/javascript/js/custom-confirm.js
avo-3.15.4 app/javascript/js/custom-confirm.js
avo-3.15.3 app/javascript/js/custom-confirm.js
avo-3.15.2 app/javascript/js/custom-confirm.js
avo-3.15.1 app/javascript/js/custom-confirm.js
avo-3.15.0 app/javascript/js/custom-confirm.js
avo-3.14.5 app/javascript/js/custom-confirm.js
avo-3.14.4 app/javascript/js/custom-confirm.js
avo-3.14.3 app/javascript/js/custom-confirm.js