Closed Badetuch closed 5 years ago
Hey @Badetuch,
you need to pass the options to the second swal()
as well:
document.getElementById("alert").addEventListener("click", function() {
swal({
title: "Info",
text: "Mit dem verbinden akzeptierst du automatisch die geltenen Regel unseres Teamspeaks!",
icon: "warning",
buttons: {
cancel: "Abbrechen",
senden: {
text: "Verbinden",
value: "verbinden"
}
}
}).then(value => {
switch (value) {
case "verbinden":
swal("Erfolgreich verbunden", {
icon: "success"
}).then(() => {
location.href = "https://google.com";
});
break;
}
});
});
Thank your so much dude. But how can i make, when i click "verbinden" that i get to another page not when i press "verbinden" and "Ok" after.
Hope u understand me :(
If you redirected to another page, as soon as you click "verbinden", you would never see the 2nd alert. If that's what you want, you could use this:
document.getElementById("alert").addEventListener("click", function() {
swal({
title: "Info",
text:
"Mit dem verbinden akzeptierst du automatisch die geltenen Regel unseres Teamspeaks!",
icon: "warning",
buttons: {
cancel: "Abbrechen",
senden: {
text: "Verbinden",
value: "verbinden"
}
}
}).then(value => {
switch (value) {
case "verbinden":
location.href = "https://google.com";
break;
}
});
});
Alternatively, you redirect after a short timeout (1 second in this case) while showing the 2nd alert:
document.getElementById("alert").addEventListener("click", function() {
swal({
title: "Info",
text:
"Mit dem verbinden akzeptierst du automatisch die geltenen Regel unseres Teamspeaks!",
icon: "warning",
buttons: {
cancel: "Abbrechen",
senden: {
text: "Verbinden",
value: "verbinden"
}
}
}).then(value => {
switch (value) {
case "verbinden":
setTimeout(() => {
location.href = "https://google.com";
}, 1000);
swal("Erfolgreich verbunden", {
icon: "success"
});
break;
}
});
});
Thanks sooooo much dude u helped my realy much. If u want i have another question opend: https://github.com/t4t5/sweetalert/issues/874
Greetings from Germany :)
Glad I could help
Hello,
Here is my code: https://hastebin.com/qusumeyino.js
When i click "verbinden" i wanna see the "succes" icon, how do i set it up? I tried it so: https://hastebin.com/ezozirogin.coffeescript And I want that when i click "verbinden" that a internet page opens.
Im realy sorry for my bad English. Hope sb can help my
Greetings from Germany :)