D
|
david22585 1/16/2021 |
I hope everyone is ok. I run several tests before add a record and today I use the "alert()" function to display the error messages to user, but I would like to use the new Sweetalert plugin, but the code below doesn´t show anything: ==================== echo " <script type=\"text/javascript\"> swal('Inclusão em andamento. Por favor, aguarde...', { buttons: false, timer: 30000, icon: 'info', }); </script>"; ===================== Any sugestions? Thanks in advance,
|
M
|
marcelorribas author 1/17/2021 |
Hi, |
D
|
david22585 1/17/2021 |
Hi, I run the tests in "Before record added" event.
if ($values["value"] == "some kind of data"){
if (proxy["error"]){
if ($values["name"] == ""){ |
M
|
marcelorribas author 1/17/2021 |
Thank you so much, David for your help. |
M
|
marcelorribas author 1/18/2021 |
Hi David, how you doing? |
M
|
marcelorribas author 1/18/2021 |
Hi David, how you doing? Only today I was able to implement your code, but unfortunately it didn´t work for me. I have created a little project to use as a test. Steps follow below: 1 - I put on "Before record added" the code below: -------------------------------- IF ($values['listorder']<>1){ $pageObject->setProxyValue("error", "Sorry, you need to type 1"); return false; } else { return true; } ------------------------------- 2 - In JavaScript OnLoad event (on Add page) ------------------------------- if (proxy["error"]){ swal({ title: "Error", text: "proxy["error"]", icon: "error", button: "Okay", timer: 5000, }); } ----------------------------- The test works ok (the record is not saved) but nothing is displayed. I can´t see what I´m doing wrong...
|
D
|
david22585 1/19/2021 |
Hi David, I think I found the problem. You can´t use double quotes in [text] parameter to display a variable name. I have altered your code and now is working great. Thanks again, ---------------------------------------- if (proxy["error"]){ swal({ title: "Sorry, we have a problem!", text: proxy["error"], icon: "error", button: "Ok", timer: 5000, }); } ---------------------------------------- Regards, Marcelo
|
M
|
marcelorribas author 1/19/2021 |
Hi Marcelo, You're exactly right. You can put in anything you want for text if you use the double quotes, but if you want to display the proxy value, you cannot use the double quotes at all. That was my bad on the code, I did a copy/paste and edit and forgot those in there by accident. Glad to see it's working!
|
D
|
david22585 1/19/2021 |
I´ve just noticied another thing: If you use the "open in popup mode" to add the record, Sweetalert doesn´t work. Nothing is displayed. Do you have any ideas how to do an workaround? Thanks,
|
M
|
marcelorribas author 1/19/2021 |
Try adding this to After Rrecored Added/Updated:
|
D
|
david22585 1/20/2021 |
Hi David, Unfortunately, the problem remains. In popup mode, nothing is displayed.
|
M
|
marcelorribas author 1/20/2021 |
I'll play with it later this afternoon or this evening (eastern United States time) and get back with a hopeful solution then.
|
D
|
david22585 1/20/2021 |
Thank you in advance.
|
M
|
marcelorribas author 1/20/2021 |
I just tried a bunch of different ways and couldn't get it to work. This may be one for Sergey to address. Sorry Marcelo.
|
M
|
marcelorribas author 1/21/2021 |
Hi David, how are you? this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){
|