Data binding not refreshing

From the docs, " Whenever the self.item of a Form changes, all Data Bindings for that Form are updated."

However, if I bind a component to a member of self.item with write back enabled, that doesn’t seem to be the case - when the component changes, the content of self.item changes as expected but the data bindings for other components stay unchanged.

Forcing a call to self.refresh_data_bindings() makes everything work perfectly but I wasn’t expecting to need that. Am I misunderstanding something here?

Here’s a clone link for a minimal demo of the problem:
https://anvil.works/build#clone:3P2XAKENQS4UGNHJ=TMGIP63JJU5CSFJCVUYIK6HA

Hi @owen.campbell,

Data Bindings for a form are updated whenever self.item is set (in fact in the form’s __setattr__, triggered when you write self.item = something). So changing self.item to point to something else will trigger a refresh, but changing some aspect of the object it points to will not. I hope that makes sense!

I’ll make sure we update the docs to make this clearer.

ahhhhh!!! Thank you kindly!

In hindsight, that explains so many instances where I’ve had to refresh data bindings and couldn’t understand why!

Now I can envisage a nice little class for anvil extras that takes a form instance in its init, exposes a dict like interface and calls the form’s refresh_data_bindings whenever it changes…

3 Likes