Skip to content
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

Attribute value is not yet defined for tag input #202

Open
renatoathaydes opened this issue Dec 7, 2022 · 0 comments
Open

Attribute value is not yet defined for tag input #202

renatoathaydes opened this issue Dec 7, 2022 · 0 comments

Comments

@renatoathaydes
Copy link

Got the following error trying to get the value of an input:

message: "Attribute value is not yet defined for tag input"

Code:

import kotlinx.browser.document
import kotlinx.html.div
import kotlinx.html.dom.append
import kotlinx.html.h2
import kotlinx.html.id
import kotlinx.html.input
import kotlinx.html.js.onKeyUpFunction
import kotlinx.html.style
import kotlinx.html.unsafe
import org.w3c.dom.HTMLElement

object HtmlIds {
    const val base58Result = "base58-result"
}

/**
 * Test application for the base58 library.
 *
 * It helps test that the code works on a browser.
 */
fun main() {
    byId("root").append {
        h2 {
            +"Enter some text:"
        }
        input {
            placeholder = "Text to encode to base58"
            onKeyUpFunction = { _ ->
                byId(HtmlIds.base58Result).textContent = value
            }
        }
        div {
            id = HtmlIds.base58Result
            style {
                unsafe { raw("padding: 10px; background: green; color: white") }
            }
        }
    }
}

private fun byId(id: String): HTMLElement {
    return (document.getElementById(id) as HTMLElement?)!!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant