Questions tagged [sweetalert2]

A responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript's popup boxes with zero dependencies. Use this tag for questions that involve using this library.

A JavaScript library for generating popup windows. It can be combined with jQuery and it returns promises.

SweetAlert2 page

SweetAlert2 CDN


Stack Overflow Quick Start Snippet

html

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9.17.1/dist/sweetalert2.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@9.17.1/dist/sweetalert2.css">

javascript

Swal.fire({
  title: 'Success!',
  text: 'Swal ready',
  icon: 'success',
  confirmButtonText: 'Cool'
})
649 questions
-1
votes
1 answer

Best way to use ajaxstop with sweetalert2

I do several ajax calls and would like to do the final swal fire once all ajax calls are done. I tried that in the code below, but obviously, it doesn't have the desired effect. Basically, what I would like is that, after the text are displayed "All…
Rajan
  • 15
  • 4
-1
votes
2 answers

How to store user input as a variable with a modal dialog library? (JavaScript)

I'm trying to save user input via alert as a variable. I actually can do it via JS using prompt, but can't implement a similar solution with sweetalert and sweetalert2 libraries. I read through their documentation and examples: …
Dimos082
  • 11
  • 1
  • 5
-1
votes
2 answers

send data from jscript to other php

I am doing a dynamicall table such as:
Value Action
-1
votes
1 answer

Vue.use(plugin) causing error: Vue is a constructor and should be called with the `new` keywor

Plugin involved - https://www.npmjs.com/package/sweetalert Code in main.js import 'bootstrap/dist/css/bootstrap.min.css'; import 'bootstrap-vue/dist/bootstrap-vue.css'; import BootstrapVue from 'bootstrap-vue'; import Vue from 'vue'; import Vuetify…
Darren Cook
  • 85
  • 1
  • 10
-1
votes
1 answer

Call PHP function from Javascript runs both functions

What is happening is I have Sweetalert2 on my page. It displays the alert fine, but when I click cancel, it runs both php functions, and not just the one needed. What should happen is when I click cancel, it takes me back to the page for the post…
Darth Mikey D
  • 95
  • 1
  • 12
-1
votes
2 answers

How can I add multiple inputs to a SweetAlert2 popup?

I have code on my website that uses a SweetAlert2 popup to let users request songs: $('#request-song').click(async function() { const { value: song } = await swal({ title: "Request a Song (please note song request won't be played unless we are…
Joshua R
  • 1
  • 1
  • 1
-1
votes
2 answers

Delete confirmation with Sweetalert2 in Vue js

I'm trying to make a sweetalert when the user clicks the delete button it will trigger a sweetalert and when the user clicks Yes, Delete it! it should make an axois request to delete the status. When the user clicks on Yes, Delete it! the sweetalert…
Yosef
  • 434
  • 1
  • 7
  • 17
-1
votes
2 answers

How do I display sweetalert2 radio options vertically?

I am working with sweetalert2 to create a popup list of radio options. My list of options are more than 3 and most are longer than 5 words. So, the display output is not nice since it is displayed horizontally, as you can see in the screenshot…
minimini
  • 3
  • 3
-1
votes
2 answers

Pause and wait for boolean response from other function

I would like to be able to have 2 functions, run 1 of them, then inside it, run another and wait for its response before continuing in an if statement. The response is manual, (yes/no). Basically something like this function function1(){ …
S_R
  • 1,488
  • 1
  • 16
  • 42
-1
votes
1 answer

sweetalert2 should redirecting to another html after clicking OK

Not showing alert, as well redirecting is not working //sweetalert2 swal({ title: "Success!", text: "Agent Created Successfully.", type: "success", }.then(function(){ …
-1
votes
1 answer

Redirection after pressing ok button Sweetalert2 and PHP

I've trying this so hard, but no luck. I'm using SweetAlert2 for a simple login service. When the login is incorrect, I want to show the error message and redirect the user to the index page. If I try only the message is working fine, but I can make…
saysmus
  • 61
  • 1
  • 12
-1
votes
1 answer

Sweet Alert Shows success but record not deleted

PHP code $query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get members"); $data = array(); while($row = mysqli_fetch_array($query)) { // preparing an array $schoolID = $row["schoolID"]; $schoolname = $row["schoolname"]; …
Sam Banana
  • 57
  • 1
  • 10
-1
votes
1 answer

PHP onclick confirm to Sweet Alert 2 confirmation

I need your help here please.I have a button which is echoed by a PHP file to a HTML file. When the button is clicked it uses window confirm() method but I want to use a sweet alert 2 modal to be displayed with yes or no option in the HTML…
Antony Star
  • 37
  • 1
  • 8
-2
votes
2 answers

Sweetalert does not work but when i test with alert it does

I recently started using Sweetalert but now I don't understand why it doesn't work. I made a function that retrieves the value of a button that I tested with alert (and it works) but as soon as I put it with sweetalert, the button is validated…
-2
votes
1 answer

Chain To Then Function While Encapsulating One in ES6

I'm a new ecmaScript6-student. I need to chain to "then" promises while encapsulating a library function. Swal is sweetAlert2 function to ask questions and get response from user, yes/no. Here is what I'm trying to do; class MyLib { …
Lost_In_Library
  • 2,783
  • 4
  • 33
  • 63
1 2 3
43
44