<@U3DE1TXKP> maybe as dynamic, then: ``` val ...
# javascript
g
@robstoll maybe as dynamic, then:
Copy code
val body = document.querySelector("body").asDynamic()
    body.foo = Foo(42)
    println(body.foo)
r
Man, today seems to be a bad day of for my examples. I actually wanted to write
document.getElementById('a').asDynamic().test = 12
. That works well, that's what I currently do but its seems wrong to do it outside of the
div
. The problem is, that the element does not yet exist (as far as I saw) at the point of
Copy code
div('a') {
//here I need somehow access to the underlying div-instance
}
If i can get hold on the div-HTMLElement instance inside the
div
then I could work with asDynamic. Do you know a way to get the element?
😅 1
g
You can try
Copy code
div('a') {
    this.asDynamic().test = 42
}
r
unfortunately not
this
refers to the receiver of the
div
function, so to a DIV instance and not the div element
g
Ahhh yes, I had forgotten how it works. The builder is a complete abstraction with no access to the underlying DOM elements. So I you should store the reference outside of the DOM and just keep an id in the DOM using a special attribute.