I'm building a Flask app that will take in and submit information about sizes from a form, will process it using Python, and will display the results on the same page. I got that working. I wanted to add dynamic fields, so a user can click to add another size. I got that working as well, and I can see in the output on the page that the function in Python is working with this additional input.
Here's the issue: when I click submit, the page reloads and the dynamic fields disappear, even though the results are still displayed below. This is pretty much a UX issue: if someone made a typo the first time, they would have to go back and add all of the fields and enter all of the info again. Plus, they wouldn't be able to see what they originially added.
I've read posts on submitting the info without reloading the page. I got that to work, but then I wasn't able to display the results of the function beneath the entry fields, since the page needed to reload, running the .py file again, in order to do that. Then I read about AJAX, which would display the input asynchronously on the original page, avoiding the page reload. However, I need the info to be processed in my .py file that has all the Flask code, and doing that, the page reloads when I use render_template() and the dynamic fields go away. Maybe there's some other way to add the Python into AJAX?
Is Jinja a thing that would be helpful here?
I feel like what I'm trying to do has to be possible somehow, but I'm totally missing how to do it. I think the method above can't logically work given the order in which these processes have to run. Any corrections of or comments on the above would be greatly appreciated!