How to close alert box in blank form

Hello there,

Please I need help closing an alert box initiated from a blank form. The alert box contains a button, that when clicked runs:

self.raise_event(‘x-close-alert’, 10)

But the alert box doesn’t close after the button is clicked.
Note: The form is a blank form.

See this project which works as you describe :

https://anvil.works/build#clone:TGT7YOITYEGODHZB=ENM3NVB6U3ILP6JJLM365SMN

Form1 shows an alert which contains Form2 as the body :

from anvil import *
from Form2 import Form2

class Form1(Form1Template):

  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)

  def form_show(self, **event_args):
    """This method is called when the column panel is shown on the screen"""
    alert(Form2(),buttons=[])

Form2 contains a button and the following code :

from anvil import *

class Form2(Form2Template):

  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)

  def button_1_click(self, **event_args):
    """This method is called when the button is clicked"""
    self.raise_event("x-close-alert",10)
4 Likes

Thank you very much @david.wylie, this works.

1 Like