But when I switch to another tab get back to current tab, the browser removes the read-only attribute of the TextField. I tried to re-run the code above but I don’t know which event will be triggered when switching tab.
How can I prevent the read-only attribute to be removed or re-run the code above? Which event will be fired when switching tab? Please help.
NOTE: I don’t want to use the editable = false or enable = false property because it will change the UI of the TextField.
try setting jmix.ui.component.mainTabSheetMode=MANAGED. In MANAGED mode, main TabSheet doesn’t unload components from the tab when the user selects another tab.
But I’d recommend adding DOM attributes via HtmlAttributes bean, rather than using JS workaround, e.g.: