I've added a SweetAlert into an existing upload Form, where upon selecting the Submit button it successfully displayed the pop-up alert. Like so:
$('#submit-btn').on('click',function(e){
e.preventDefault();
var form = $('.pt_upld_page_frm');
swal.fire({
title: "Are you sure?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, submit it!",
closeOnConfirm: false
}).then((result) => {
if (result.isConfirmed) { $('.pt_upld_page_frm').submit(); }
});
});
But, my goal is to have the "Yes, submit it" to actually submit the chosen uploaded file. But it didn't upload it.
So, I added code from farther down the file, into the alert, like so:
$('#submit-btn').on('click',function(e){
e.preventDefault();
var form = $('.pt_upld_page_frm');
swal.fire({
title: "Are you sure?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, submit it!",
closeOnConfirm: false
}).then((result) => {
if (result.isConfirmed) {
$('.pt_upld_page_frm').ajaxForm({
//$('#upload-form form').ajaxForm({
url: '{{LINK aj/ffmpeg-submit}}?hash=' + $('.main_session').val(),
beforeSend: function() {
$('#submit-btn').attr('disabled', true);
$('#submit-btn').val("{{LANG please_wait}}");
},
success: function(data) {
if (data.status == 200) {
window.location.href = '{{LINK home}}';
}
else if(data.status == 402){
swal({
title: '{{LANG error}}',
text: data.message,
type: 'error',
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'OK',
buttonsStyling: true,
confirmButtonClass: 'btn btn-success',
}).then(function(){
window.location.href = '{{LINK upload-video}}';
},
function() {
window.location.href = '{{LINK }}';
});
}
else {
$('#submit-btn').attr('disabled', false);
$('#submit-btn').val('{{LANG publish}}');
Snackbar.show({text: '<div>'+ data.message +'</div>'});
}
}
});
//});
});
}
});
});
But now it submits successfully, but doesn't display the Alert first. The goal is to have the "Yes, submit it" to actually submit
Any guidance is welcomed.