Hey
On the success modal, I was wondering if there ws a way i could add few buttons which would tell the user something like
'Hey, job a done successfully"
'Now you can do one of the below"
"Option1-link" "Option2-link" "Option3-link"
I now this is not what the plugin is for but if i had to tweak this plugin to start accepting a jsn like {text:'', link:''} a collection of it and render buttons accordingly... where would i begin with ?
AFAIK, you can't. The two button system is hardcoded throughout the script. It would require a significant amount of changes to make it work. What you can do is use the html option to add your own buttons in the body of the modal.
I got this to work, some javascript i had to right, might not be the correct way to do this, but worked for me. Sharing it here
if (buttons) {
var className = ".sweet-alert";
var container = "<div class='sw-btn-container'><div class='buttons'></div></div>";
$(className).after("h2").append(container);
var buttonDiv = ".sweet-alert .buttons";
_.each(buttons, function (item) {
if (item.url) {
$(buttonDiv).append("<a class='confirm' href='" + item.url + "'>" + item.text + "</a>");
} else if (item.onclick) {
$(buttonDiv).append("<a class='confirm' onclick='" + item.onclick + "'>" + item.text + "</a>");
}
});
}
I might be a little late, but I hope this can help.
That plugin its just what I needed, thanks for the info :D
Most helpful comment
I might be a little late, but I hope this can help.
https://github.com/andrew-mestas/swalExtend/tree/master