I’m trying to get an alert to display or not display, depending on the output of a form submission. Here are the steps that I’d like to happen:
User submits form (POST request).
Form input is sent to external API (POST request) and external API response is received.
Alert display conditionally, depending on the output of the API response.
I have everything working except the “conditionally” part (I can get the alert to show on a button click, and I’ve checked that the API response is as I expect in Chrome’s developer tools). I’ve been trying to get the conditional alert working with the “Show” dynamic attribute on the alert where I select the relevant part of the form’s “data” and do a string comparison on that. Is this the right way to do this, or am I supposed to do this a diffferent way?
Hi,
That does sound like the correct way of doing it.
Try to create a regular binding on say a P tag and see what the values are and why the condition might be failing.
Here’s the value and results of string comparisons of my relevant variable (output_safety_check) when I bind them to P tags:
Here’s the code for the dynamic value of the P tag that’s showing true:
Here’s the code for the alert’s dynamic “Show” attribute:
I got Wappler to generate both of these by clicking on the relevant stuff in the “Data Bindings” popup (didn’t manually write this code). The only difference I see between these two is that the alert one doesn’t have content at the beginning of it; when I add that manually, it still doesn’t seem get the alert to show.
Ah, good debugging idea. Don’t know why I didn’t try that haha. Unfortunately, putting “1”, “true”, etc. in the “When” field for the dynamic show doesn’t make it work either. So it seems like the dynamic attribute “Show” isn’t working, at least not as we expect. Does it work for you?