Forums: Button with async function (sweetalert2) - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Button with async function (sweetalert2) Rate Topic: -----

#1 User is offline   Kristian Karlsson 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 84
  • Joined: 02-November 09

Posted 17 August 2018 - 07:44 AM

I want to use the nice looking Sweetalert 2 Sweetalert in button code to open popup and ask for input from user.
I can succesfully use simple flavor of Sweetalert, but when i try to take input from user i need to use await inside the code and that makes the page render this fault: "Uncaught SyntaxError: await is only valid in async function"
From what i been able to find regarding this i need to declare the click handler function as async.
Is that possible in any way?

Example of code i'm trying to use on the "Client Before" of button:
const {value: email} = await swal({
  title: 'Input email address',
  input: 'email',
  inputPlaceholder: 'Enter your email address'

if (email) {
  swal('Entered email: ' + email)

Tried to add this before my code without any luck:

Anyone have any idea how to solve this?

/ Kristian

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users