How to delete old data from alert?

Hey guys, I’m trying to follow along with this tutorial:
https://anvil.works/learn/tutorials/database-backed-apps

Here’s my progress so far:
https://anvil.works/build#clone:N5U5K34KSFW5EEGH=Z2QKVAEZNRVQHFXHVAUOF22K

What I’m having trouble with is this:

As you can see, the alert data remains, and doesn’t get cleared out… How do I fix this?

I can’t clone because your database is too large…

Without looking at the code I would say there are probably a number of choices to achieve clearing the form.

Think about where you initiate your form. If you’ve initiated it in the main form like

self.add_article = AddArticleForm()
...

def add_article_button_click(self, **event_args):
  alert(self.add_article, buttons = [])

Using the alert is just showing the AddArticleForm that you initiated earlier.
So perhaps in the AddArticleForm's hide event, you could write some code to clear the boxes.

Alternatively instead of initiating the AddArticleForm inside your main form and then showing this form in an alert…
You could do

alert(AddArticleForm(), buttons=[])

This way the AddArticleForm is initiated inside the alert and when the alert is closed the form is closed and a new form will load each time the alert is triggered.

1 Like

Sorry to respond so late… I’ve deleted all the data from the data tables… can you give it another look?

I think you just need to do something like

self.new_article={} within your save_clicked condition

1 Like

That works! Thank you! I’m assuming that the = {} just creates a new empty object? Sorry… I’m new to Python.

Yeah it just reassigns self.new_article to an empty dictionary. Otherwise self.new_article remembers its state

1 Like