I am using Bootrap 4 modal in vuejs which is called as:
> <a href="#" class="" data-toggle="modal" :data-email="user.email"
> data-target="#exampleModal">Delete</a>
I dynamically create onclick handler for a button in modal like:
mounted() {
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var email = button.data('email')
var modal = $(this)
modal.find('.modal-footer #delete').attr('onclick', "deleteUser('"+ email +"')")
})
deleteUser is defined in methods section:
methods:
deleteUser(email) {
.....
}
As soon as I click Yes button in modal dialog, I get this error thrown:
Uncaught ReferenceError: deleteUser is not defined
at HTMLButtonElement.onclick (users:1)
onclick @ users:1
How to solve this problem? I tried let $this = this and used $this.deleteUser but this does not work either.
The answers given in How to access the correct this
inside a callback? are not related to vuejs and bootstrap 4 modal.