-
-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
run_method
and getElement
return inconsistent types of elements
#3019
Comments
Hi @chrschorn, That's a great observation. When implementing and extending To support explicit access to Vue components or HTML elements - without breaking the existing API -, we might want to introduce new functions like But besides that, what can we do about |
Description
Hi, originally I wanted to implement a "scroll to element" functionality in an application I'm working on. You can use scrollIntoView() on the DOM node to achieve that. But: how can I get the DOM node for any NiceGUI element?
The issue I ran into:
element.run_method("scrollIntoView")
and it works. This seems to be the case when the NiceGUI element is just a simple dom node to begin with, e.g.ui.label
which is a div$el
to get the DOM node of the vue component.Here are some examples that work with
run_method
, then a customscroll_to
I wrote and thenui.input
which I couldn't get to work at all:Is there already an easy way to get the root DOM node of the NiceGUI element? According to https://nicegui.io/documentation/run_javascript, it should be
getElement
, but this either returns a DOM node, vue component where$el
refers to the root DOM node or, in cases likeui.input
, something where even$el
points to a non-DOM object.It would be good to have a reliable way to get the DOM node for an element. Maybe
run_method
could have a bool argumentdom_element
? Providing a javascript function documented onrun_javascript
could also work.The text was updated successfully, but these errors were encountered: