sweetalert
sweetalert copied to clipboard
Feature Suggestion: Multiple Content Objects
It might make sense to allow multiple content objects to be specified as an array.
At present, content must be specified in the following way:
swal({
content: {
element: "p",
attributes: {
innerText: "Test element"
}
}
});
It would be nice to be able to do this:
swal({
content: [
{
element: "p",
attributes: {
innerText: "Enter your password below"
}
},
{
element: "input",
attributes: {
placeholder: "Password"
}
}
]
});
Happy to submit a PR, just wanted to get a feel for what the opinion on this suggestion is before doing anything.
Why not have a single div
element and add the p
and input
tags as children to it?
It would be nice if this was supported, I often find a lot of my use cases that could be solved by swal don't work because of the "hacky" nature of the content
attribute.
I would love to see content supporting an array of objects (as above) which then return the value of each content element (assuming it's some form of input) as part of the promise response when an action is triggered.
@t4t5 do you have any plans to implement this at all?
Same here. Would love to have this feature in a library such great besides that.
We can do a work around this issue.
const wrapper = document.createElement('div'); wrapper.innerHTML = YOUR_DYNAMIC_HTML;
swal({ title: 'Test Title', text: 'Test Text', content: wrapper });