Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Connect a KVar to an <input> value

Pre-release
Pre-release
Compare
Choose a tag to compare
@sanity sanity released this 12 Apr 16:35
· 1833 commits to master since this release

You can now connect a KVar to the value of an InputElement and it will update automatically when the element is edited by the user in-browser:

    Kweb(port = 1245) {
        doc.body.new {
            val i1 = input(placeholder = "Type here")
            val i2 = input(placeholder = "Or here")

            val commonString = KVar("")

            i1.value = commonString
            i2.value = commonString

           // The contents of each text box can be edited and will stay in sync.
        }
    }

For more information see Binding a KVar to an InputElement value.