ui.element.id is only reflected for some elements in HTML - what's the reason / concept? #4087
-
QuestionRecently I was trying to localize an ui.input on the screen using ui.run_javascript(f'getElement({element.id}).getBoundingClientRect();') to attach a custom (hovering) suggestion view to it. The execution always failed because getElement fails as the element.id is represented in the DOM of some html elements like in case of a ui.label like in your documentation example or ui.column I assume this is intended but is there a reliable concept behind it? What kind of elements really also have theirs ID assigned as attribute in the DOM and which ones not? I now ended up wrapping my input field in a container, but (I assume so) had there been another solution to localize my input field without doing so? Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @Alyxion, Vue translates a Quasar components like QBtn into an HTML element See #3842 (comment) for reference:
Without an ID defined by NiceGUI, |
Beta Was this translation helpful? Give feedback.
Hi @Alyxion,
Vue translates a Quasar components like QBtn into an HTML element
<button>
which receives all props like theid
attribute. But, for reasons I don't fully understand, other components like QInput are translated into<label>
without any user-defined props. The<input>
element itself is nested somewhere within<label>
, receives props, but theid
attribute is randomly generated to match thefor
attribute of the<label>
element.See #3842 (comment) for reference: