SweetAlert 2 with 3 buttons
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 02:17 AM
Has anyone been successful with having a sweetalert with more than 2 buttons?
I have download and installed sweetalert2 xml from the store but I still cant get 3 buttons to appear on a alert. I tried the example that’s provided
https://sweetalert.js.org/guides/#advanced-examples but still no luck.
Example with 3 buttons:
swal("A wild Pikachu appeared! What do you want to do?", {
buttons: {
cancel: "Run away!",
catch: {
text: "Throw Pokéball!",
value: "catch",
},
defeat: true,
},
})
.then((value) => {
switch (value) {
case "defeat":
swal("Pikachu fainted! You gained 500 XP!");
break;
case "catch":
swal("Gotcha!", "Pikachu was caught!", "success");
break;
default:
swal("Got away safely!");
}
});
Thanks,
Ahmed

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 06:08 AM
Hey,
I got your linked example to work with the following code:
In this example, I run the function on click but with an alert it depends on how you want to trigger it, if you share the process I might be able to help further.
I hope this helps.
HTML:
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<div>
<button ng-click="c.open()">please work</button>
</div>
Client Script:
function() {
/* widget controller */
var c = this;
c.open = function() {
swal("A wild Pikachu appeared! What do you want to do?", {
buttons: {
cancel: "Run away!",
catch: {
text: "Throw Pokéball!",
value: "catch",
},
defeat: true,
},
})
.then((value) => {
switch (value) {
case "defeat":
swal("Pikachu fainted! You gained 500 XP!");
break;
case "catch":
swal("Gotcha!", "Pikachu was caught!", "success");
break;
default:
swal("Got away safely!");
}
});
}
}
Result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2019 06:10 AM
Thanks for the example.
I wanted to get it work on a client script on the platform view but having no luck.
Did you install sweetalert2 xml from the store?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 09:28 AM
No, I just call the .js file in my HTML TEMPLATE.
example:
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
Just to confirm, are you trying to get this to work for the Service Portal or something else?