Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How and where would I modify to add multiple buttons on the success modal #511

Closed
yrshaikh opened this issue Jan 12, 2016 · 4 comments
Closed

Comments

@yrshaikh
Copy link

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 ?

@daxpandhi
Copy link

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.

@yrshaikh
Copy link
Author

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>");
                }
            });
        }

@andrew-mestas
Copy link

I might be a little late, but I hope this can help.

https://github.com/andrew-mestas/swalExtend/tree/master

@JavierCabezas
Copy link

That plugin its just what I needed, thanks for the info :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants