Can't use the raise_event method on the parent repeating panel from the item template

What I’m trying to do:

Raise the x-refresh event on a repeating panel within a data grid from the repeating panel’s item template to put focus on the first element of the last line of the repeating panel.

I don’t get this error when I use the method in a standard anvil event, only in a JS Event and it seems to apply to all instances of raise_event, even on self (which is passed to the function itself) and to raise_event running within other method calls called from this function.

What I’ve tried and what’s not working:
I can use self.parent.items to successfully add a new row to the repeating panel, but any method call like raise_event gives the NoneType Error.

Code Sample:

self.parent.raise_event('x-refresh')

I put this within an instance method of the item template that triggers on focus loss from the last item in the template row to add an additional row.

I register this event with JQuery to the last button like this (record_button_dom is a JQuery object made from get_dom_node obj) and add_row is my method:

record_button_dom.focusout(lambda event: self.add_row(event))

Are you able to provide a clone link or a minimal reproducible example here?

It’s very hard to help with the information you’ve provided. Specifically it sounds like you’re doing something things (like messing with the DOM) that might bypass some of Anvil’s registration, hence why self.parent is None.

Usually, if you want to add elements to a repeating panel, then you should do so by reassigning to repeating_panel.items, i.e. repeating_panel.items = repeating_panel.items + [new_element] or something. This will trigger the appropriate registration which I assume is where parent gets defined.

There’s a lot of guess work in my response here. As I said a clone link would really help.