Open ingrocha opened 6 years ago
Same issue here. Any advice?
hii @fmendoza and @ingrocha, we have same issue, after google an hour I've found the solution, here is example code from this source
$("#btn-show-feedback").click(function(){
var textarea = document.createElement('textarea');
textarea.rows = 6;
textarea.className = 'swal-content__textarea';
// Set swal return value every time an onkeyup event is fired in this textarea
textarea.onkeyup = function () {
swal.setActionValue({
confirm: this.value
});
};
swal({
text: 'How can we improve this site?',
content: textarea,
buttons: {
cancel: {
text: 'Cancel',
visible: true
},
confirm: {
text: 'Submit',
closeModal: false
}
}
}).then(function (value) {
if (value && value !== true && value !== '') {
var data = { feedback: value };
$.ajax({
url: '/send-feedback',
method: 'POST',
data: data,
success: function (res) {
swal('Success', 'Feedback successfully submitted.', 'success');
},
error: function (err) {
swal('Error', 'Unfortunately, an error occurred. Please try again.', 'error');
}
});
}
if (value === true || value === '') {
swal.close();
}
});
});
@hellodit, works like a charm! But have i side effect...
This part not work more, attributes: { value: startValue, },
When i call result it gets 'true' it dosent get the vaue in the textarea