ContentEditable label cannot retrieve updated .text

What I’m trying to do:
I have a label in Anvil but the .text property does not update, how can I get the current value of the label?

What I’ve tried and what’s not working:
I am trying to create a text input that has an automatic width and could achieve this by using a label and setting it to ContentEditable via JavaScript querySelectorAll to find all with attribute role
Trying to get the value via anvil it returns the original value not the edited value

Code Sample:

print(self.label.text)
# does not match the actual edited label ``` 

Welcome to the forum!

You’d need to use Javascript to get the new value, using the anvil.js bridge. anvil.js.get_dom_node(self.label) will get you the DOM node for the label, you can then use whatever Javascript you’d normally use to get the new contents.

3 Likes