Skip to content

$watch not work in x-init within the modal component #86

@armandoperez083

Description

@armandoperez083

Describe the bug
I found that modals are not working because they $watch not work in x-init if it is removed if it works

Solution

` x-init="() => {

    let el = document.querySelector('#modal-id-{{ $id }}')

    let modal = new bootstrap.Modal(el);

    
        if (show) {
            modal.show()
        } else {
            modal.hide()
        }
   

    el.addEventListener('hide.bs.modal', function (event) {
      show = false
    })
}"`

Desktop (please complete the following information):

  • OS: W11
  • Browser Edge
  • Version 101.0.1210.53

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions