in 2021
Improved Alerts
Replace Bootstrap Modal alerts by SweetAlert2
How can i use it with an simple alert js?
alert(“Alert”);//Style SweetAlert2
in 2021
Improved Alerts
Replace Bootstrap Modal alerts by SweetAlert2
How can i use it with an simple alert js?
alert(“Alert”);//Style SweetAlert2
You may simply use, e.g.
ew.alert(“xxx”);
in server event not works
eg:
userfn.js:
function myAlert() {
ew.alert(“message”);
return true;
}
userfn.php
// Page Loading event
function Page_Loading(){
echo ‘’;//works only if alert(“”);
}
I would like to verify a value in a table of the db and after user login, view the status with SweetAlert2 popup and change the value in db to not show it again with confirmation
how can i implement it
eg:
Swal.fire({
title: ‘Are you sure?’,
text: “You won’t be able to revert this!”,
icon: ‘warning’,
showCancelButton: true,
confirmButtonColor: ‘#3085d6’,
cancelButtonColor: ‘#d33’,
confirmButtonText: ‘Yes, delete it!’
}).then((result) => {
if (result.isConfirmed) {
Swal.fire(
‘Deleted!’,
‘Your file has been deleted.’,
‘success’
)
}
})
window.myAlert = function() { … };
You should avoid outputting JavaScript in server side Page_Loading server event, it is not suitable, although it will work if you write it correctly.
In fact, you do not need to write your own function (e.g. myAlert()), just call ew.alert() or Swal.fire() directly in Startup Script.
i have to run queries to query the db so i would use server side events like Page_Loding or UserID_Loading but i would use the new poupup to show the message and reset the value in the db after confirmation
To pass server side value to client side, you may use SetClientVar(), see: https://discourse.hkvstore.com/t/set-global-javascript-variable/2450/1
arbei wrote:
To pass server side value to client side
And for pass client side value to server side with an Alert popup?
You may see the topic Lookup Table → “Ajax by API and Client Scripts” in the help file.
i’m trying this, but it doesn’t read me the if condition,
result.isConfirmed)
Swal.fire({
title: ‘Are you sure?’,
text: “You won’t be able to revert this!”,
icon: ‘warning’,
showCancelButton: true,
confirmButtonColor: ‘#3085d6’,
cancelButtonColor: ‘#d33’,
confirmButtonText: ‘Yes, delete it!’
}).then((result) => {
if (result.isConfirmed) {
var object = “MyTable”, MyID = encodeURIComponent(‘1’);//get row with id 1
$.get(“/api/”+ object +“Edit/” + MyID, function(res) {
if (res && res.success) {
var row = res[object];
alert(JSON.stringify(row)); // Show output JSON
row[“flag1”] = “0”;
} else {
alert(res.failureMessage);
}
});
}
})
in the doc it’s so API but url it’s not same: url-> http_://localhost/mws/MyTableEdit/1
$.get(“/api/Edit/” + object + “/” + key, function(res) {
$.get(“/api/”+ object +“Edit/” + MyID, function(res) { //it should be right?
For API, the url should be: /api/edit//, see the topic REST API in the help file.
but how can I pass e value of field?
/api/edit/{table}/{keyFieldValue}
Update an existing record by key, eg.
/api/edit/cars/1
Trademark=2&…
$.get(ew.getApiUrl([“edit”, “clienti”, 1]), function(res) {// value for field?
// your code
});
arbei wrote:
For API, the url should be: /api/edit//, see the topic REST API in the help file.
Note that it is:
POST /api/edit/{table}/{keyFieldValue}
so you should use $.post() and send your data in the “data” setting, see: https://api.jquery.com/jquery.post/.