https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
javascript
  • b

    bashor

    07/29/2020, 11:39 AM
    Claudflare added support Kotlin(/JS) for writing workers (their serverless solution) along with few other languages compiled to JS. https://blog.cloudflare.com/cloudflare-workers-announces-broad-language-support/
    🎉 6
    • 1
    • 1
  • s

    Sebastian Aigner

    07/29/2020, 3:51 PM
    🛠️ In case you haven’t seen it yet: we’re happy to share a preview version of
    kotlinx-nodejs
    with you, which provides typesafe Node.js API bindings for Kotlin/JS! :kotlin-flag: You can find installation instructions for
    kotlinx-nodejs
    in the blogpost for 1.4.0-RC or on GitHub. Have fun experimenting - and don’t forget to report any encountered issues!
    🔥 1
    🚀 6
    g
    • 2
    • 4
  • s

    spierce7

    07/30/2020, 2:25 AM
    I’m using the react template to start an app for the 1.4.0 RC. Even the basic template runs VERY slow with webpack (I’m guessing it has something to do with the packed output being a 22 MB file). For dev, I’d like to not rely on webpack because it increases my compile times substantially. What are my options for removing webpack from the dev experience, and getting my compile times to something sane?
    a
    • 2
    • 3
  • f

    frank

    07/30/2020, 10:47 AM
    I'm testing react app and I have problems in render cycle with useEffect(). I added a dependency array in my useEffect for prevent render loop but ignores dependency array and render 2 times. Any hint what's going on? Code:
    val (mensajes, setMensajes) = useState(emptyArray<Json>()) //{ nick, msg, type}
    val (users, setUsers)       = useState(emptyArray<Json>())
    
    useEffect(listOf(users)) {
      socket.on("loginUser") { data ->
          console.log("OnloginUser")
          val noOfUsers = data["numOfUsers"] as Int
          val item = getMsgJson("", getParticipantsMessage(noOfUsers), "log")
          val items = mensajes.plus(item)
    	  
          setMensajes(items) //render 1 time
          setUsers(data["usersList"]) //render 2 time
      }
    }
    c
    a
    • 3
    • 8
  • c

    christophsturm

    07/31/2020, 10:39 AM
    is jest supported as javascript testRunner? in kotlinjstest i find only
    useKarma
    and `useMocha`methods.
    🇳🇴 1
    i
    a
    • 3
    • 7
  • c

    christophsturm

    07/31/2020, 12:38 PM
    are there any plans to support typescript and javascipt source code in kotlin/js projects, for example
    src/jsMain/js
    and
    src/jsMain/ts
    (like kotlin/jvm supports java sourcecode)
    t
    • 2
    • 10
  • a

    Alexander Weickmann

    07/31/2020, 10:17 PM
    Hey all. Trying very hard to get react-hot-loader working with KotlinJs. Anybody managed to do that? I am always getting error "Cannot call a class as a function" 😞
    a
    r
    +2
    • 5
    • 15
  • j

    janvladimirmostert

    08/01/2020, 9:24 AM
    I take it non-empty constructors are no longer supported in 1.4.0-rc? This used to work fine up to 1.4-M3
    @JsExport
    @ExperimentalJsExport
    class LoginState(
    	json: String? = null,
    ) {
    now in RC the compiler complains:
    e: java.lang.IllegalStateException: Can't find name for declaration FUN SYNTHESIZED_DECLARATION name:LoginState_init_$Create$ visibility:public modality:FINAL <> (json:kotlin.String?, $mask0:<http://kotlin.Int|kotlin.Int>, $marker:kotlin.js.DefaultConstructorMarker?) returnType:com.rezproperty.modules.account.state.LoginState
    and neither is adding a second constructor after removing the param from the default constructor?
    @JsExport
    @ExperimentalJsExport
    class LoginState() {
    
    	@JsName("LoginStateWithJson")
    	constructor(json: String): this() {
            ...
    	}
    e: java.lang.IllegalStateException: Can't find name for declaration FUN SYNTHESIZED_DECLARATION name:LoginState_init_$Create$ visibility:public modality:FINAL <> (json:kotlin.String) returnType:com.rezproperty.modules.account.state.LoginState
    :youtrack: 1
    r
    • 2
    • 5
  • j

    Jorrit

    08/01/2020, 7:06 PM
    In IDEA, is there a button somewhere to "view generated JS" for selected code, analogous as with Kotlin/JVM you're able to view generated bytecode? If there is, where is it? I've been locating and opening the generated JS file manually so far.
    🇳🇴 1
    r
    b
    • 3
    • 3
  • j

    Jorrit

    08/02/2020, 8:47 PM
    Trying to use the new ir compiler, setting
    kotlin.js.compiler=ir
    in
    gradle.properties
    , all is fine generally, but if I use
    --continuous
    in my the run configuration for the
    run
    gradle task, the first compile works, but as soon as I change a file and save, the build crashes with a file not found on the <ModuleName>.js file. Restarting the task again works fine. It seems doubtful I'm the first to try this, so I'm guessing I'm doing something wrong here. Anyone have an easy answer, or YT ?
    b
    i
    • 3
    • 2
  • j

    Jorrit

    08/05/2020, 12:37 AM
    (a) So I'm wanting to use some js stdlib classes that are incomplete, and I'm doing this to fix it (in this example, adding
    join()
    to `Uint16Array`:
    @JsName("Uin16Array")
    public external open class Uint16ArrayX : Uint16Array {
        // copy/paste constructors from Uint16Array here
        fun join(separator: String = definedExternally): String
    }
    This seems to work, but it also feels like I need to wash my hands now. I can use an
    Uint16ArrayX
    anywhere a
    Uint16Array
    is asked for. The only caveat is that going from X to original needs an unsafeCast, but that is mildly inconvenient at worst. I didn't find a way to patch Uint16Array directly. The compiler wont accept external extensions to an external class. Is there a better way to do this than above? Ofcourse I could just (Uint16Array).asDynamic().join(...) but that's not the point of this exercise. (b) It seems CharArray uses Uint16Array internally (IntArray to Int32Array, etc), but am I correct in my understanding that CharArray's functions are otherwise pure kotlin and not (or rarely) mapped to their Uint16Array counterparts (which aren't declared at this point anyway) ? (c) For TypedArrays (and a few other things) it seems Kotlin's definitions are a bit outdated/missing. I looked in Kotlin source GitHub to see if I might contribute at some point, but it is unclear to me what comes from where. There's idl files referenced to which the original urls no longer serve (are the kotlin files autogenerated from them .idl or hand-translated?). There are several copies of the definitions as well. Where to start here for possible (far) future pull request ?
    a
    • 2
    • 3
  • j

    Jorrit

    08/05/2020, 12:54 AM
    Additionally, I found that using bare data classes (consisting only of primitive types, and nested data classes, creating quite complex structures) with javascript functions expecting objects and vice versa works perfectly well:
    data class Test(val i: Int, val s: String)
    var t = Test(1, "hello")
    someJavascriptFunctionExpectingObject(t)
    var t = js("{i: 1, s: 'hello'}").unsafeCase<Test>()
    In hindsight it seems obvious that this works. But when Googling around for this I ran into all sorts of parsers and lengthy code ending up with the same thing but significantly slower. Is there something wrong with doing it this way, other than losing presence/type checks for the fields? Is this likely to break in unexpected ways (such as?) or is it fine to use in tightly controlled cases? Thank you for coming to my TED talk 🙂
    a
    • 2
    • 4
  • b

    Brandon Saunders

    08/05/2020, 10:13 AM
    does anyone here know why splitChunks in the webpack definition would cause the output to no longer go to the distributions folder? If I add the following to my webpack config
    config.optimization.splitChunks = {
        minSize: <someNumber>,
        maxSize: <theSameNumber>
     };
    I get nothing in my distributions folder. If I remove it, the distributions folder gets created on build. Any ideas?
    • 1
    • 3
  • n

    Nicholas Bilyk

    08/05/2020, 8:40 PM
    In 1.4-rc, how do I change the js output filename? I don't want to change the module name, I want to append the version to the filename for cache busting reasons.
    b
    b
    i
    • 4
    • 14
  • v

    Vampire

    08/05/2020, 11:28 PM
    I wrote a GitHub action using TypeScript. Now I wanted to rewrite the whole thing in Kotlin/JS. I applied
    kotlin("js") version "1.3.72"
    I called
    kotlin { target { nodejs() } }
    I declared all the dependencies I had in
    package.json
    now with
    implementation(npm("...", "..."))
    Now my current problem is how do I make those dependencies properly usable using Dukat? I've read you can set the project property
    kotlin.js.experimental.generateKotlinExternals = true
    to enable automatic Dukat magic. But either this is wrong, or I did something wrong or not fully. When I run
    gradlew build
    , I get this:
    > Task :generateExternals
    events.js:187
          throw er; // Unhandled 'error' event
          ^
    
    Error: write EPIPE
        at afterWriteDispatched (internal/stream_base_commons.js:150:25)
        at writeGeneric (internal/stream_base_commons.js:141:3)
        at Socket._writeGeneric (net.js:771:11)
        at Socket._write (net.js:783:8)
        at doWrite (_stream_writable.js:431:12)
        at writeOrBuffer (_stream_writable.js:415:5)
        at Socket.Writable.write (_stream_writable.js:305:11)
        at Readable.ondata (_stream_readable.js:727:22)
        at Readable.emit (events.js:210:5)
        at Readable.read (_stream_readable.js:525:10)
    Emitted 'error' event on Socket instance at:
        at errorOrDestroy (internal/streams/destroy.js:108:12)
        at Socket.onerror (_stream_readable.js:759:7)
        at Socket.emit (events.js:215:7)
        at errorOrDestroy (internal/streams/destroy.js:108:12)
        at onwriteError (_stream_writable.js:446:5)
        at onwrite (_stream_writable.js:473:5)
        at internal/streams/destroy.js:50:7
        at Socket._destroy (net.js:664:5)
        at Socket.destroy (internal/streams/destroy.js:38:8)
        at afterWriteDispatched (internal/stream_base_commons.js:150:17) {
      errno: 'EPIPE',
      code: 'EPIPE',
      syscall: 'write'
    }
    • 1
    • 1
  • p

    Peter Fortuin

    08/06/2020, 10:44 AM
    Hi guys, Is there a way to configure the npm registry to use when building a kotlin js module?
    :yes: 1
    t
    s
    • 3
    • 3
  • j

    Jorrit

    08/06/2020, 1:01 PM
    Is there a guide somewhere to package my JS module (make it a library) and publish it to maven? First local, ultimately bintray (or does js-only go to mavenCentral) ?
    👍 1
    t
    • 2
    • 2
  • v

    Vampire

    08/06/2020, 1:53 PM
    After I got my
    EPIPE
    problem from above solved, I'm a step further, but highly confused. Maybe someone can shed some light here. • If I only have
    implementation(npm("@actions/core", "1.2.4"))
    as npm dependency, automatic Dukat runs fine now, producing a
    core.module_@actions_core.kt
    file with the external definitions, but all exported methods are in the default package, not in an npm-package specific package, is that expected or can this be changed? I imagine this could easily cause conflicts if you add more dependencies. • Also, with only
    @actions/core
    as dependency, it then compiled fine, but doing
    ./gradlew run
    complains with
    ReferenceError: setFailed is not defined
    • Now it gets even uglier, I added the other dependencies I have (or at least had in the TS variant, some are probably superfluous now):
    implementation(npm("@actions/cache", "1.0.1"))
    implementation(npm("@actions/core", "1.2.4"))
    implementation(npm("@actions/exec", "1.0.4"))
    implementation(npm("@actions/http-client", "1.0.8"))
    implementation(npm("@actions/io", "1.0.2"))
    implementation(npm("@actions/tool-cache", "1.6.0"))
    implementation(npm("semver", "7.3.2"))
    implementation(npm("null-writable", "1.0.5"))
    implementation(npm("node-filter-async", "2.0.0"))
    and now while Dukat still duly does its work (and produces 316! Kotlin files o_O), the compiler is super unhappy, throwing 802 errors at me.
    f
    t
    • 3
    • 38
  • p

    PHondogo

    08/07/2020, 8:46 AM
    Hello! When building gradle multi module js project build folder in root directory is created and Intellij Idea after each build indexing it. What configuration show I add to exclude this folder from indexing? I tried to use idea gradle plugin with excluded build folder but it did not help. Please help me with advice!
    s
    • 2
    • 2
  • f

    fwilhe

    08/07/2020, 5:54 PM
    Hi I'm looking for open source examples of multiplatform (jvm/js) kotlin code-bases that demonstrate how well kotlin can serve as a language to be consumed by both ecosystems. Anyone aware of some?
    f
    r
    +3
    • 6
    • 8
  • d

    darkmoon_uk

    08/09/2020, 9:03 AM
    In running JS Browser test; it looks like the toolchain (K/JS, Karma, Chrome Headless) is also executing my JS Application and not just the Unit Tests.
    r
    • 2
    • 5
  • j

    John O'Reilly

    08/09/2020, 9:33 AM
    I'm updating Kotlin/JS code in https://github.com/joreilly/BikeShare/blob/master/web/src/main/kotlin/App.kt to start using
    kotlin-react-router-dom
    wrapper ....it looks like correct property gets passed to
    StationList
    but
    useEffectWithCleanup
    block isn't being executed 2nd time I click on a link (so isn't loading the data)....anyone know what I should be doing differently here?
    t
    • 2
    • 3
  • r

    Rob Murdock

    08/11/2020, 2:31 AM
    Is adding support to allow running node commands using the installation from the Kotlin js plugin on the roadmap? I haven’t found a supported way to do this at the moment 😢
    i
    • 2
    • 7
  • g

    Gunslingor

    08/11/2020, 5:08 PM
    I could use a hand; Trying to learn how to use js modules in my kotlin JS apps for browser. I'm stuck on defining this lamba part; all untested just trying to get off the ground:
    @JsModule("grapesjs")
    external class Grapes {
        fun init(lambda: () -> Unit): Grapes = definedExternally
    }
    
    class WebEditorViewController {
        val grapes = Grapes().init {
            val container = "#gjs"
            val fromElement = true
        }
    }
    And here is what the actual JS is supposed to look like, from the hello world examples
    const editor = grapesjs.init({
      container: '#gjs',
      fromElement: true,
      height: '300px',
      width: 'auto',
      storageManager: false,
      panels: { defaults: [] },
    });
    t
    a
    r
    • 4
    • 73
  • g

    Gunslingor

    08/12/2020, 3:18 AM
    What's up wiwth browserDevelopmentRun, is there a way to avoid webpack and dce... just trying to debug here, tired of waiting on webpack...lol, because I'm missing something obvious
    g
    i
    • 3
    • 36
  • m

    Marc Knaup

    08/12/2020, 11:28 AM
    How do I access the standard
    Intl
    functionality? I’m trying to use
    Intl.Locale
    .
    t
    • 2
    • 2
  • v

    Vampire

    08/12/2020, 1:31 PM
    What is
    warning "workspace-aggregator-6f2c6a0d-778d-49e5-9792-0c1b7ca65d3f > setup-wsl > kotlinx-coroutines-core@1.3.8" has incorrect peer dependency "kotlin@1.3.71".
    telling me? Did I do something wrong? Is there a Koltin/JS error? ...? This is displyed when I have
    implementation(npm("kotlinx-coroutines-core", "1.3.8"))
    and refresh in IntelliJ. Actually mainly wondering, because I'll replace that with
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.8")
    as the
    npm
    variant does not provide navigation to definition.
    a
    • 2
    • 4
  • v

    Vampire

    08/12/2020, 2:17 PM
    And next question, how do I access things from
    process
    in Kotlin/JS for node.js besides using for example
    private val platform = js("process.platform") as String
    r
    • 2
    • 8
  • v

    Vampire

    08/12/2020, 6:28 PM
    Aaand next question, how is one supposed to use coroutines in Kotlin/JS for node.js? You cannot do
    runBlocking
    as it does not exist for Kotlin/JS intentionally. Actually right now I just declared the
    fun main()
    as
    suspend fun main()
    and it seems to work properly. Just want to double-check whether this is the correct way. 🙂
    t
    a
    • 3
    • 10
  • m

    Mark Iantorno

    08/12/2020, 6:43 PM
    Hey, does anyone have any experience doing multiple file upload with a styledInput in kotlin? Right now, I have my code like this:
    class FileUploadComponent : RComponent<FileUploadProps, RState>() {
        override fun RBuilder.render() {
            styledInput(InputType.file, name = "fileUpload", formEncType = InputFormEncType.multipartFormData) {
                css {
                    display = Display.none
                }
                attrs {
                    id = "FileUploadInput"
                    onInputFunction = {
                        event -> println("onInputFunction :: $event")
                        val input = document.getElementById("FileUploadInput") as HTMLInputElement
                        println("VALUE -> ${input.value}")
                    }
                }
            }
            styledButton {
                +"Upload Files"
                attrs {
                    name = "UploadFileButton"
                    onClickFunction = {
                        val field = document.getElementById("FileUploadInput") as HTMLInputElement
                        field.click()
                    }
                }
            }
        }
    }
    But that only does one file at a time, and not multiple files. I know if HTML you would just add something like
    <input id='file-input' type='file' multiple/>
    and it would work, but I can't figure out how to add the multiple attribute to this input... Any help would be greatly appreciated.
    j
    • 2
    • 4
Powered by Linen
Title
m

Mark Iantorno

08/12/2020, 6:43 PM
Hey, does anyone have any experience doing multiple file upload with a styledInput in kotlin? Right now, I have my code like this:
class FileUploadComponent : RComponent<FileUploadProps, RState>() {
    override fun RBuilder.render() {
        styledInput(InputType.file, name = "fileUpload", formEncType = InputFormEncType.multipartFormData) {
            css {
                display = Display.none
            }
            attrs {
                id = "FileUploadInput"
                onInputFunction = {
                    event -> println("onInputFunction :: $event")
                    val input = document.getElementById("FileUploadInput") as HTMLInputElement
                    println("VALUE -> ${input.value}")
                }
            }
        }
        styledButton {
            +"Upload Files"
            attrs {
                name = "UploadFileButton"
                onClickFunction = {
                    val field = document.getElementById("FileUploadInput") as HTMLInputElement
                    field.click()
                }
            }
        }
    }
}
But that only does one file at a time, and not multiple files. I know if HTML you would just add something like
<input id='file-input' type='file' multiple/>
and it would work, but I can't figure out how to add the multiple attribute to this input... Any help would be greatly appreciated.
j

janvladimirmostert

08/13/2020, 2:42 PM
you can probably do something like this.attributes.add("multiple") or something like this.attributes["multiple"] = "multiple" should work as well
m

Mark Iantorno

08/13/2020, 2:42 PM
I figured it out, it's jsut a tag of
multiple = true
in the
attrs
section
thanks though
j

janvladimirmostert

08/13/2020, 2:42 PM
awesome!
View count: 5