Open wondertalik opened 6 years ago
Not sure if this addresses your current problem but wherever you're triggering this swal:
let email = self.cliente.email
swal({
title: "Separar las adreces de correu electrònic amb coma",
buttons: {
cancelar: {
text: "Cancel · lar",
value: "something other than null"
},
si: {
text: "Si",
value: email
}
},
content: {
element: "input",
attributes: {
placeholder: "Correus",
type: "text",
value: email
}
}
})
.then((value) => {
console.log(document.getElementById('input_mail').value)
console.error(value);
})
The flow basically sends the value of the default email, but if the user changes the input's value, then you can grab it in the then clause by targetting the input element. Dirty, i know, but might help you get by. Also, if you dont have a problem with the default cancel being null, you can always deal with it in the then by checking for null and doing something about it :)
I have the same problem. if there are no changes to the input field, default value is empty
Same for me too. Sweet Alert returns empty value if I don't make any change in default input field value
the same as me
This issues is still a big problem. How is it not resolved already?
document.getElementById("btn").onclick = function() {
swal("Test default value", {
buttons: {
cancel: true,
ok: {
value: "Button value"
}
},
content: {
element: "input",
attributes: {
value: "Default value"
}
}
})
.then((result) => {
console.log(result);
});
}
Expected behavior. If the input text is changed, the new value should be passed as the result. If the input text is unchanged, the default value should be passed as the result.
What happens: 1 - If input text is changed, and [Enter] button is pressed, the new value is passed as expected. This is ok.
2 - If the [Enter] button is pressed without making any changes, NULL value is passed.
3 - If the [Ok] button is pressed/clicked, the BUTTON value gets passed regardless of whether the input text was changed or not.
Please fix this. Otherwise this library is kind of useless.
Also note that this problem occurs even with the official examples: See the second example under https://sweetalert.js.org/guides/#using-dom-nodes-as-content
Hi, all. Awesome library. But have a problem with default value in the input. If i press cancel - value is null, if si - value is empty. if i did some changes in the input get correct value.