confirmation Message on editor pre_submit
confirmation Message on editor pre_submit
hey allan i want to used confirmation Message on pre_submit but i want to use sweetalert2
and not the confirm option, but i can make it work, the pre submit always make submit to form
here my code:
editor.on('preSubmit', function (e, data, action) {
if (action != "remove") {
//editor.field('orderNumber').val()
var IsUsed = false;
var OrderNum = editor.field('orderNumber').val();
var DayTripId = editor.field('DayTrip.DayTrip_Id').val();
var data = table.data().toArray();
data.forEach(function (row, i) {
if (row.DayTrip.DayTrip_Id == DayTripId && row.Order_Num == OrderNum) {
return;
}
else if (row.Order_Num == OrderNum)
{
IsUsed = true;
return false;
}
});
if (IsUsed == true) {
Swal.fire({
title: 'אזהרה!',
text: "מספר יום טיול קיים כבר במסלול,האם ברצונך להחליף ביניהם?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'כן, החלף!',
cancelButtonText: 'ביטול'
}).then(function (result) {
if (result.value) {
return true;
}
});
}
}
});
This discussion has been closed.
Answers
You need to return false from the function if you want Editor to not submit (like you are on line 15). It does not currently accept a Promise in return, so what you would need to do is something like:
I've obviously shortened it a bit, but does that make sense?
Allan
allan like this its still make submit and only after show message
Sorry - you should add
return false;
after theSwal.fire()
call so the default action is cancelled.Allan