run_method
and getElement
return inconsistent types of elements
#3019
Labels
run_method
and getElement
return inconsistent types of elements
#3019
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: