Sha256: 749f45753fb3a8456bda87f7d98a89e9163a8522459b8755b30985b7c7cbbbf4

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

import { Controller } from '@hotwired/stimulus'
import * as bootstrap from 'bootstrap'

export default class extends Controller {
  static outlets = ['asociable']
  static targets = ['response']

  modalPuntero = null

  connect (e) {
    this.modalPuntero = new bootstrap.Modal(this.element)
    this.modalPuntero.show()
    document.addEventListener("turbo:before-cache", () => {
      this.element.remove()
    }, { once: true })
  }

  responseTargetConnected (e) {
    const newObject = JSON.parse(e.dataset.response)
    this.asociableOutlet.completarCampo(newObject)
    this.element.remove()
  }

  openModal () {
    this.modalPuntero.show()
  }

  disconnect (e) {
    this.modalPuntero.hide()
    this.modalPuntero.dispose()
  }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.16 pg_associable/app/javascript/modal_controller.js