Problem
I'm using SweetAlert2, opening an alert with custom HTML inside it, that shows a few input boxes. I want to use the normal confirm/cancel buttons from SweetAlert2 to send the value of those inputs to a socket.
Question
How can I get the values of those inputs, using the normal SweetAlert2 buttons? Please do not suggest using normal inputs or HTML buttons as that is a workaround and I don't want that.
Environment
I use jQuery, SweetAlert2, and a few unrelevant libraries such as Vue.js and Socket.io, etc.
Code
function addUser() {
swal({
html: `
<div class="field">
Email:
<p class="control has-icons-left">
<input class="input" type="email" placeholder="Email">
<span class="icon is-small is-left">
<i class="mdi mdi-email"></i>
</span>
</p>
</div>
<div class="field">
Name:
<p class="control has-icons-left">
<input class="input" type="text" placeholder="Name">
<span class="icon is-small is-left">
<i class="mdi mdi-account"></i>
</span>
</p>
</div>
<div class="field">
Password:
<p class="control has-icons-left">
<input class="input" type="text" placeholder="Password">
<span class="icon is-small is-left">
<i class="mdi mdi-key"></i>
</span>
</p>
</div>
<div class="field">
Level:
<p class="control has-icons-left">
<input class="input" type="text" placeholder="Level">
<span class="icon is-small is-left">
<i class="mdi mdi-arrow-up"></i>
</span>
</p>
</div>
`,
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
confirmButtonClass: 'button is-success has-right-spacing',
cancelButtonClass: 'button is-danger',
buttonsStyling: false,
showCancelButton: true
})
}